blog-ldap-csharp-example
blog-ldap-csharp-example copied to clipboard
ldap server not avaialble
tried with
var client = new Client("cn=developer,dc=shihadeh,dc=intern", "shihadeh.intern", "developer_pass", "LDAP//localhost:389");
but always getting ldap server not available
Same server when i tried to access via java code then it is binding
public static void main(String[] args) {
String url = "ldap://localhost:389";
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, url);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "cn=developer,dc=shihadeh,dc=intern");
env.put(Context.SECURITY_CREDENTIALS, "developer_pass");
try {
DirContext ctx = new InitialDirContext(env);
System.out.println("connected");
System.out.println(ctx.getEnvironment());
// do something useful with the context...
ctx.close();
} catch (AuthenticationNotSupportedException ex) {
System.out.println("The authentication is not supported by the server");
} catch (AuthenticationException ex) {
System.out.println("incorrect password or username");
} catch (NamingException ex) {
System.out.println("error when trying to create the context");
}
System.console().readLine();
}