I am using LdapTemplate to use LDAP authentication, I am able to succesfully find users in file system but authenticate method returns false and argues that my password is wrong.
I have debugged it and it succesfully finds the object it finds a match but password does not match.
dn: dc=obssjobs,dc=com
objectclass: top
objectclass: domain
objectclass: extensibleObject
dc: obssjobs
# Organizational Units
dn: ou=groups,dc=obssjobs,dc=com
objectclass: top
objectclass: organizationalUnit
ou: groups
dn: ou=people,dc=obssjobs,dc=com
objectclass: top
objectclass: organizationalUnit
ou: people
# Create People
dn: uid=john,ou=people,dc=obssjobs,dc=com
objectclass: top
objectclass: hrexpert
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: John Doe
sn: John
uid: john
password: secret
dn: uid=jihn,ou=people,dc=obssjobs,dc=com
objectclass: top
objectclass: hrexpert
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Jihn Die
sn: Jihn
uid: jihn
password: secret
dn: uid=jahn,ou=people,dc=obssjobs,dc=com
objectclass: top
objectclass: hrexpert
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Jahn Dae
sn: Jahn
uid: jahn
password: 123
Authentication Method
public boolean authenticate(String username, String password) {
AndFilter filter = new AndFilter();
filter.and(new EqualsFilter("objectclass", "hrexpert")).and(new EqualsFilter("cn", username));
return ldapTemplate.authenticate(DistinguishedName.EMPTY_PATH, filter.toString(), password);
}
Here is my test in main, logs "false"
@PostConstruct
public void setup(){
boolean authenticated=hrExpertService.authenticate("Jahn Dae", "123");
log.info("authenticated: " + authenticated);
}