View RSS Feed


LDAP Programming with JNDI

Rate this Entry
by , 07-07-2012 at 05:24 PM (711 Views)
Objects present in LDAP server could be manipulated by connecting with server. Also, you may require the authentication with server. For making connections with server get a reference of DirContext interface to an object. This is done with class InitialDirContext that would be taking hashtable.

Given code could be used for authentication and connection of user with LDAP server. It shall be noted that simpler authentications are used over here. Simpler kind of authentications include full qualified DN as well as clear text password of user to be receive by the LDAP server.In order to make clear text password avoidable of getting exposed, this mechanism shall be used along with some encrypted channel if support is provided by LDAP servers.

Java Code:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "LdapCtxFactory");
// specify where the ldap server is running
env.put(Context.PROVIDER_URL, "ldap://");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "cn=Directory Manager");
env.put(Context.SECURITY_CREDENTIALS, "password");
// Create the initial directory context
DirContext ctx = new InitialDirContext(env);

Submit "LDAP Programming with JNDI" to Facebook Submit "LDAP Programming with JNDI" to Digg Submit "LDAP Programming with JNDI" to Submit "LDAP Programming with JNDI" to StumbleUpon Submit "LDAP Programming with JNDI" to Google