Cert based ldap authentication
843811Apr 17 2008 — edited Jun 4 2008Hello all,
Ideas of how to do this, examples are always preferred. Either from local workstation's IDE or through a servlet page,
how would one perform a bind to an LDAP server using a clients certificate (X509Certificate)?
Using "simple" method is easy, well documented, and not a problem:
// Set up the environment for creating the initial context
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:636");
// Specify SSL
env.put(Context.SECURITY_PROTOCOL, "ssl");
// Authenticate as S. User and password "mysecret"
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "cn=S. User, ou=NewHires, o=JNDITutorial");
env.put(Context.SECURITY_CREDENTIALS, "mysecret");
// Create the initial context
DirContext ctx = new InitialDirContext(env);
// ... do something useful with ctx
But with certificate, seems not as straightforward.
Any help is appreciated.
SK