Two Laptop Bag
The moose likes Security and the fly likes unable to do ssl authentication using ldaps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Security
Bookmark "unable to do ssl authentication using ldaps" Watch "unable to do ssl authentication using ldaps" New topic

unable to do ssl authentication using ldaps

Dharmakumar Gajendran

Joined: Feb 22, 2010
Posts: 20

I have written a program to authenticate the login user with my organisations ldap directory. I have given the code below,

public boolean authenticate() {

String userName = "username";
String password = "password";
Hashtable<String, String> env = new Hashtable<String, String>();


env.put(Context.PROVIDER_URL, "ldap://,DC=com,DC=au");
env.put(Context.SECURITY_AUTHENTICATION, "Simple");
* Review : Please Move the domain name to the properties file.
env.put(Context.SECURITY_CREDENTIALS, password);
DirContext ctx = null;
NamingEnumeration results = null;
try {
try {
ctx = new InitialDirContext(env);

} catch (AuthenticationException authEx) {
} catch(Exception e) {

The authentication is successful with the above code. Now I am trying to authenticate with ldaps:// and using 'ssl' instead of 'simple'. But the authentication has failed and I am getting the below error.

javax.naming.AuthenticationNotSupportedException: ssl
at com.sun.jndi.ldap.sasl.LdapSasl.saslBind(
at com.sun.jndi.ldap.LdapClient.authenticate(
at com.sun.jndi.ldap.LdapCtx.connect(
at com.sun.jndi.ldap.LdapCtx.<init>(
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(
at javax.naming.spi.NamingManager.getInitialContext(
at javax.naming.InitialContext.getDefaultInitCtx(
at javax.naming.InitialContext.init(
at javax.naming.InitialContext.<init>(
at SimpleLdapClient.authenticate(
at SimpleLdapClient.main(

Can any one please help to resolve this issue.

Thanks in advance.
Joanne Neal

Joined: Aug 05, 2005
Posts: 3742
It's the protocol type, not the authentication type, that you need to set to 'ssl'

Dharmakumar Gajendran

Joined: Feb 22, 2010
Posts: 20
Hi Joanne,

Thanks for your suggestion. I have tried this. But still getting the same error.

I agree. Here's the link:
subject: unable to do ssl authentication using ldaps
jQuery in Action, 3rd edition