【问题标题】:Spring Ldap LDAP: error code 32 - 0000208DSpring Ldap LDAP:错误代码 32 - 0000208D
【发布时间】:2015-11-27 06:48:23
【问题描述】:

我正在开发使用 LDAP 进行身份验证的应用程序。我正在使用 spring LDAP 模板进行身份验证,但得到以下响应

{
    "message": "[LDAP: error code 32 - 0000208D: NameErr: DSID-031001E5, problem 2001 (NO_OBJECT), data 0, best match of:\n\t''\n\u0000]; nested exception is javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001E5, problem 2001 (NO_OBJECT), data 0, best match of:\n\t''\n\u0000]; remaining name '/'"
}

下面是spring的配置

<beans:bean id="contextSource"
    class="org.springframework.ldap.core.support.LdapContextSource">
    <beans:property name="base" value="" />
    <beans:property name="url" value="<LDAP-URL>" />
    <beans:property name="userDn" value="<USER-DN>" />
    <beans:property name="password" value="<PASSWORD>" />
</beans:bean>

<beans:bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
    <beans:constructor-arg ref="contextSource" />
</beans:bean>

Java 代码:

AndFilter filter = new AndFilter();
filter.and(new EqualsFilter("objectclass", "person")).and(new       EqualsFilter("sAMAccountName", username));
boolean result = ldapTemplate.authenticate(LdapUtils.emptyLdapName(),               filter.toString(), password);

我是 LDAP 新手,任何帮助或示例都会非常棒。

【问题讨论】:

    标签: java spring spring-mvc active-directory ldap


    【解决方案1】:

    如果您已经设置了基础,则无需在进一步的操作中指定完整的 dn。你确定你有正确的服务器规格吗?错误 32 通常会搞砸前缀或目录配置!

    【讨论】:

    • 服务器配置看起来很好,当我更改为错误密码时,它说身份验证失败,这意味着它已通过身份验证并在之后失败
    • 这是正确答案。我将完整的基本 DN(例如ou=users,dc=ad,dc=company,dc=com)传递给authenticate。将其更改为空字符串有效。
    【解决方案2】:

    根据之前的正确答案,searchBase 必须为空。我正确的过滤器是:

    FilterBasedLdapUserSearch userSearch = new FilterBasedLdapUserSearch("", "(&(CN={0})(memberOf=cn=Group-BioBank,OU=HyperV,OU=Services,DC=bob,DC=uk))", contextSource);
    

    这个过滤器就像一个魅力。 (Spring4.x)

    过滤器解释: https://confluence.atlassian.com/kb/how-to-write-ldap-search-filters-792496933.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-22
      • 1970-01-01
      • 2013-01-25
      • 2019-05-26
      • 2011-12-31
      相关资源
      最近更新 更多