java: ldap NamingException
I try to use LDAP authentication.
public boolean login(String username, String password){
AndFilter filter = new AndFilter();
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", username));
return ldapTemplate.authenticate(DistinguishedName.EMPTY_PATH, filter.toString(), password);
}
Because I used ActiveDirectory server, I have this exception:
javax.naming.NamingException: [LDAP: error code 1 - 000020D6: SvcErr: DSID-03100754, problem 5012 (DIR_ERROR), data 0]; remaning name = '/'
In my opinion, this exception showed, because I use DistinguishedName.EMPTY_P开发者_高级运维ATH
.
How I can to fix this problem?
The actual error you have is the following:
//
// MessageId: ERROR_DS_MISSING_SUPREF
//
// MessageText:
//
// No superior reference has been configured for the
// directory service. The directory service is therefore
// unable to issue referrals to objects outside this forest.
//
#define ERROR_DS_MISSING_SUPREF 8406L
This can be found by converting the error code you have (000020D6) into decimal and checking in winerror.h.
In my opinion you need to supply a base DN for the search you are performing. The one you have supplied (supposedly by default, when not specified) is /, which is not a valid DN. If you domain name is domain.example.com, a valid base DN will be DC=domain,DC=example,DC=com.
精彩评论