01 September 2009

Using LDAP as authentication in JAAS with Java

A simple example of how to use LDAP as an authentication back end in Java when using JAAS:
DefaultConfig {
 com.sun.security.auth.module.LdapLoginModule REQUIRED
     userProvider="ldap://myhost:myport/"
     authIdentity="uid={USERNAME},ou=users,ou=system"
     useSSL=true
     debug=true;
};

Change the myhost and myport. The above example assumes that the users exist in the LDAP tree in ou=system,ou=users with the uid set to the user name. I'm not sure on how the file would look like if the LDAP server is a Windows Active Directory (perhaps this will be a future blog entry).

More information on the LDAP JAAS module: http://java.sun.com/javase/6/docs/jre/api/security/jaas/spec/com/sun/security/auth/module/LdapLoginModule.html

No comments:

Post a Comment