File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes LDAP authentication using ssl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

LDAP authentication using ssl

Dharmakumar Gajendran
Greenhorn

Joined: Feb 22, 2010
Posts: 20
Hi,

I am writing 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.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18875
    
  40

duplicate topic... CarefullyChooseOneForum

http://www.coderanch.com/t/566101/sockets/java/ldap-authentication-ssl


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
GeeCON Prague 2014
 
subject: LDAP authentication using ssl