How do I create an authenticated session to an LDAP server?
Created May 4, 2012
Steve Czulewicz
The authentication is provided when you create the InitialDirContext. Take a look at the snippet below...
private Hashtable _env = new Hashtable(); private InitialDirContext _ctx = null; // Authentication is controlled by the following environment // All values are Strings // Refer to javax.naming.Context // Authentication method. May also be 'none' or 'Strong' _env.put(Context.SECURITY_AUTHENTICATION, "simple"); // Distiguished name of user to authenticate _env.put(Context.SECURITY_PRINCIPAL, "cn=username,ou=orgunit,o=company"); // Password or certificate signature _env.put(Context.SECURITY_CREDENTIALS, "myPassword"); this._ctx = new InitialDirContext(this._env);