Spring Security AD LDAP:错误代码1 - 000004DC:LdapErr:DSID-0C0906E8

时间:2013-06-07 02:23:52

标签: spring-security spring-ldap

我正在尝试从Spring安全性连接Ldap,导致连接错误。有人可能会建议这种配置有什么问题,

  

UsernamePasswordAuthenticationFilter - 尝试验证用户时发生内部错误。       org.springframework.security.authentication.InternalAuthenticationServiceException:在LDAP处理期间发生了未分类的异常;嵌套异常是javax.naming.NamingException:[LDAP:错误代码1 - 000004DC:LdapErr:DSID-0C0906E8,注释:为了执行此操作,必须在连接上完成成功绑定。,data 0,v1db1];剩余名称'ou =用户,dc = aaa,dc = bbb,dc = ccc,dc = dddd'       在org.springframework.security.ldap.authentication.LdapAuthenticationProvider.doAuthentication(LdapAuthenticationProvider.java:191)

配置文件有,

<sec:authentication-manager alias="myAuthenticationManager">
    <sec:authentication-provider ref="myAuthenticationProvider"/>
</sec:authentication-manager>

<bean id="myAuthenticationProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
    <constructor-arg ref="ldapBindAuthenticator"/>
    <constructor-arg ref="ldapAuthoritiesPopulator"/>
</bean>

<bean id="ldapBindAuthenticator" class="org.springframework.security.ldap.authentication.BindAuthenticator">
    <constructor-arg ref="contextSource" />
    <property name="userSearch" ref="userSearch"/>
</bean>

<bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
    <constructor-arg index="0" value="ou=Users,dc=aaa,dc=bbb,dc=ccc,dc=dddd"/>
    <constructor-arg index="1" value="(sAMAccountName={0})"/>
    <constructor-arg index="2" ref="contextSource"/>
    <property name="searchSubtree" value="true"/>
</bean>

<bean id="ldapAuthoritiesPopulator" class="com.xxxx.MyLdapAuthoritiesPopulator">
    <property name="userDao" ref="userDao"/>
</bean>

<bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
    <constructor-arg value="ldaps://aaa.com:123/DC=aa,DC=bb,DC=cc,DC=dd"/>
    <property name="base" value="DC=aa,DC=bb,DC=cc,DC=dd" />
    <!-- <property name="anonymousReadOnly" value="true"/> -->

</bean>

1 个答案:

答案 0 :(得分:7)

让我们假设用户尝试使用用户名XXX和密码YYY登录。通常,LDAP身份验证的工作方式如下:

  1. 使用技术帐户绑定到LDAP
  2. 使用用户名XXX =&gt;搜索用户得到他的DN
  3. 尝试使用找到的DN和密码YYY
  4. 绑定到LDAP

    您的错误表明您没有正确执行第一步(技术帐户绑定)。

    尝试将userDn和密码添加到您的上下文源(这来自official JavaDoc):

    <bean id="contextSource"
            class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
        <constructor-arg value="ldap://monkeymachine:389/dc=springframework,dc=org"/>
        <property name="userDn" value="cn=manager,dc=springframework,dc=org"/>
        <property name="password" value="password"/>
    </bean>
    
相关问题