jQuery in Action, 2nd edition*
The moose likes EJB and other Java EE Technologies and the fly likes Webapp and LDAP authentication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Webapp and LDAP authentication" Watch "Webapp and LDAP authentication" New topic
Author

Webapp and LDAP authentication

Roby Kappa
Greenhorn

Joined: Oct 28, 2007
Posts: 19
Hi,

I'm trying to authenticate user and password in a form of my web application on LDAP server.

For do this, I wrote:

Hashtable<String,String> env = new Hashtable<String,String>(4);
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://......:389/DC=.....,DC=....");
env.put(Context.SECURITY_PRINCIPAL, userid);// User
env.put(Context.SECURITY_CREDENTIALS, password);// Password

try {
new InitialDirContext(env);
log.info("User " + userid + " authenticated in LDAP mode");
} catch (AuthenticationException e) {
log.error("User " + userid + " authentication failed");
}

It works... BUT only for a few users! For others, existent and with valid password, the code throws an exception!

Access to Context is the same thing to verify password correctness? If they are different, I need another piece of code for the second thing?

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Webapp and LDAP authentication