How do I create an authenticated session to an LDAP server?

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);

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact