I have installed open LDAP which is ruinning on port default port 389, i want to search all people in the directory, i am using code i found on this site
final String ldapAdServer = "ldap://";
final String ldapSearchBase = "ou=People,dc=maxcrc,dc=com";
final String ldapUsername = "Manager";
final String ldapPassword = "secret";
final String ldapAccountToLookup = "*";
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.SECURITY_AUTHENTICATION, "simple");
if(ldapUsername != null) {
env.put(Context.SECURITY_PRINCIPAL, ldapUsername);
}
if(ldapPassword != null) {
env.put(Context.SECURITY_CREDENTIALS, ldapPassword);
}
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, ldapAdServer);
//ensures that objectSID attribute values
//will be returned as a byte[] instead of a String
env.put("java.naming.ldap.attributes.binary", "objectSID");
// the following is helpful in debugging errors
//env.put("com.sun.jndi.ldap.trace.ber", System.err);
Context ctx = new InitialContext(env);
LdapContext ctxLap = new InitialLdapContext();
but getting error like
Exception in thread "main" javax.naming.InvalidNameException: [LDAP: error code 34 - invalid DN]
i think this is problem with host name ,which i am not able find correctly how can i find url to which i need to connect?
"in your build.xml file