hi,
i am getting that exception while using LdapTemplate.authenticate method.
i am getting uid and password from JSP and on valid password the method return TRUE, but on wrong password, the throws exception :
Exception :
org.springframework.ldap.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]; nested exception is javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
Caused by: javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.jav a:2985)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCt x.java:2931) AndFilter filter = new AndFilter()
.and(new EqualsFilter(LDAPEnum.OBJ_CLASS.getValue(), LDAPEnum.PERSON_CLASS.getValue()))
.and(new EqualsFilter(LDAPEnum.UID.getValue(), uid));
My Method :
public Object authenticate(String uid, String password) {
DistinguishedName dN = this.getNameForUser(uid);
boolean authenticated = false;
AndFilter filter = new AndFilter()
.and(new EqualsFilter(LDAPEnum.OBJ_CLASS.getValue(), LDAPEnum.PERSON_CLASS.getValue()))
.and(new EqualsFilter(LDAPEnum.UID.getValue(), uid));
authenticated = ldapTemplate.authenticate(DistinguishedName.EMPTY_ PATH, filter.toString(), password);
if(authenticated) {
return this.getUserEntity(uid);
}
return null;
}
LDAPEnum Class :
public enum LDAPEnum {
O("o"),
DC("dc"),
OU("ou"),
CN("cn"),
UID("uid"),
OBJ_CLASS("objectClass"),
PERSON_CLASS("person");
private final String value;
private LDAPEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
Thats happen only when password is wrong. kindly give feedback,
Thanks


Reply With Quote
