Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to do ssl authentication using ldaps

 
Dharmakumar Gajendran
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");

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

} catch (AuthenticationException authEx) {
authEx.printStackTrace();
} catch(Exception e) {
e.printStackTrace();
}


The authentication is successful with the above code. Now I am trying to authenticate with ldaps://simple.com.au 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(LdapSasl.java:100)
at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:214)
at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2694)
at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:293)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:198)
at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:83)
at SimpleLdapClient.authenticate(SimpleLdapClient.java:69)
at SimpleLdapClient.main(SimpleLdapClient.java:142)

Can any one please help to resolve this issue.

Thanks in advance.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's the protocol type, not the authentication type, that you need to set to 'ssl'
 
Dharmakumar Gajendran
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joanne,

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

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic