【问题标题】:java: ldap NamingExceptionjava: ldap 命名异常
【发布时间】:2011-08-12 07:01:17
【问题描述】:

我尝试使用 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(DistinguishedName.EMPTY_PATH, filter.toString(), password);
}

因为我用的是ActiveDirectory服务器,所以有这个异常:

javax.naming.NamingException:[LDAP:错误代码 1 - 000020D6:SvcErr:DSID-03100754,问题 5012 (DIR_ERROR),数据 0];重命名 = '/'

在我看来,出现了这个异常,因为我使用了DistinguishedName.EMPTY_PATH

我该如何解决这个问题?

【问题讨论】:

  • 我尝试使用 ldapTemplate.authenticate(ctxt.getNameInNamespace(), filter.toString(), password);和其他变体,但我的问题没有解决......
  • 活动目录中没有uid,只有sAMAccountName

标签: java active-directory ldap


【解决方案1】:

您遇到的实际错误如下:

//
// 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。如果您的域名是 domain.example.com,则有效的基本 DN 将是 DC=domain,DC=example,DC=com

【讨论】:

  • 非常感谢大家。
猜你喜欢
  • 2014-11-25
  • 1970-01-01
  • 1970-01-01
  • 2014-02-05
  • 2012-07-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多