java:ldap命名异常
我尝试使用LDAP身份验证java:ldap命名异常,java,active-directory,ldap,Java,Active Directory,Ldap,我尝试使用LDAP身份验证 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(Disti
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);
}
因为我使用了ActiveDirectory服务器,所以出现了以下异常:
javax.naming.NamingException:[LDAP:错误代码1-000020D6:SvcErr:DSID-03100754,问题5012(DIR_错误),数据0];还押名称='/'
在我看来,出现了这个异常,因为我使用了distrignizedName.EMPTY\u PATH
如何解决此问题?您的实际错误如下:
//
// 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
这可以通过将错误代码(000020D6)转换为十进制并检入winerror.h来找到
在我看来,您需要为正在执行的搜索提供一个基本DN。您提供的DN(默认情况下,未指定时)是/,它不是有效的DN。如果您的域名是domain.example.com,则有效的基本DN将是DC=domain,DC=example,DC=com。I尝试使用ldapTemplate.authenticate(ctxt.getNameInNamespace(),filter.toString(),password);和其他变体,但我的问题没有解决…active directory中没有
uid
,只有sAMAccountName
。非常感谢各位。