My ldiff file looks like this
dn:uid=test,ou=users,dc=example,dc=com
objectclass:person
objectclass:inetOrgPerson
objectclass:organizationalPerson
objectclass:top
givenName: test
title:test
uid:test
cn:test
sn:sdf
userPassword: 81dc9bdb52d04dc20036dbd8313ed055
mail: [email protected]
creatorsName: cn=Directory Manager,cn=Root DNs,cn=config
modifiersName: cn=Directory Manager,cn=Root DNs,cn=config
The userPassword is hashed in portal db using MD5 with hex encoding. Also enabled pre-encoded-password to true but doesnt help.
The plain text password for the above userPassword is "1234" and I have a sample java program to authenticate the same
public static void main(String[] args) throws NamingException {
final String ldapAdServer = "ldap://0.0.0.0:389";
final String ldapUsername = "uid=test,ou=People,dc=example,dc=com";
final String ldapPassword = "81dc9bdb52d04dc20036dbd8313ed055;
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.SECURITY_AUTHENTICATION, "simple");
if (ldapUsername != null) {
env.put(Context.SECURITY_PRINCIPAL, ldapUsername);
}
if (ldapPassword != null) {
env.put(Context.SECURITY_CREDENTIALS, ldapPassword);
}
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, ldapAdServer);
env.put("java.naming.ldap.attributes.binary", "objectSID");
DirContext ctx = new InitialDirContext(env);
}
Replacing the userPassword in the java program always gives "Invalid Authentication Exception"
Attached is the setting of OpenDJ OPENDJ Passpword policy
My requirement is we have an portal whose passwords is stored in db in MD5 with hex encoding the portal is integrated to the ldap for every password change the ldap is updated with hashed value , but the above java program doesnt work at all . Need serious help .
Thanks.