connecting to open LDAP using java -
i have installed open ldap ruinning on port default port 389, want search people in directory, using code found on 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 objectsid attribute values //will returned byte[] instead of string env.put("java.naming.ldap.attributes.binary", "objectsid"); // next 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
exception in thread "main" javax.naming.invalidnameexception: [ldap: error code 34 - invalid dn]
i think problem host name ,which not able find correctly how can find url need connect?
exception in thread "main" javax.naming.invalidnameexception: [ldap: error code 34 - invalid dn]
i think problem host name, not able find correctly
no. it's problem dn. dn not hostname. if hostname problem, connect exception of kind. if ldap error code, proof connected ldap server.
it's problem manager dn. shouldn't logging in ldap root business relationship anyway. that's openldap itself. create business relationship sufficient privilege , utilize that.
ldap
No comments:
Post a Comment