【问题标题】:Spring security 2.0.5 LDAP authentication setup w/Active DirectorySpring security 2.0.5 LDAP 身份验证设置 w/Active Directory
【发布时间】:2011-01-12 18:30:06
【问题描述】:

我一直在尝试让 LDAP 身份验证与此应用程序 (apache Roller) 一起工作,这真是太棒了。似乎它只是“填充正确的字段并开始”,但我仍在尝试对数据库进行身份验证(默认身份验证方法)。

我不明白是什么告诉 spring-security 使用一个身份验证管理器而不是另一个,所以这可能是首先要改变的事情。在花了两天时间阅读文档之后,没有更接近弄清楚。

<beans:bean id="ldapUserSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
    <beans:constructor-arg index="0" value="CN=stuff,DC=domain"/>
    <beans:constructor-arg index="1" value="uid={0}"/>
    <beans:constructor-arg index="2" ref="initialDirContextFactory"/>         
    <beans:property name="searchSubtree" value="true"/>           
</beans:bean>     

<beans:bean id="ldapAuthProvider" class="org.springframework.security.providers.ldap.LdapAuthenticationProvider">
    <beans:constructor-arg>
        <beans:bean class="org.springframework.security.providers.ldap.authenticator.BindAuthenticator">
            <beans:constructor-arg ref="initialDirContextFactory"/>
            <beans:property name="userSearch" ref="ldapUserSearch"/>
        </beans:bean>
    </beans:constructor-arg>
    <beans:constructor-arg ref="jdbcAuthoritiesPopulator"/>
</beans:bean>    

<beans:bean id="jdbcAuthoritiesPopulator" class="org.apache.roller.weblogger.ui.core.security.AuthoritiesPopulator">
    <beans:property name="defaultRole" value="groupNameUserHasToBelongTo"/>
</beans:bean>

【问题讨论】:

    标签: java spring configuration spring-security spring-ldap


    【解决方案1】:

    我们需要更多详细信息来帮助您。如果有任何错误消息,您会看到什么错误消息,请复制堆栈跟踪。

    我注意到在 BindAuthenticator 中,您可以指定上下文源和 userDnPatterns,而不是创建 ldapUserSearch bean。

    <bean id="ldapAuthProvider"
            class="org.springframework.security.providers.ldap.LdapAuthenticationProvider">
      <constructor-arg>
        <bean class="org.springframework.security.providers.ldap.authenticator.BindAuthenticator">
          <constructor-arg ref="contextSource">
          </constructor-arg>
            <property name="userDnPatterns">
              <list>
                  <value>CN={0},OU=Users,OU=_Units,DC=corporate,DC=mycompany,DC=com</value>
              </list>
            </property>
            <property name="userAttributes">
                <list>
                    <value>objectSID</value>
                    <value>userPrincipalName</value>                    
                </list>
            </property>
        </bean>
      </constructor-arg>
        <constructor-arg>
          <bean class="com.security.AuthoritiesPopulator">
          </bean>
        </constructor-arg>
        <property name="userDetailsContextMapper">
            <bean class="com.corp.CustomLdapUserDetailsMapper"/>
        </property>
        <security:custom-authentication-provider/>
    </bean>
    

    【讨论】:

    • 是的,我在研究中看到了您的博文。我也试过了,但这里的问题似乎并不在于映射,而是在于调用 ldapAuthProvider。我根本没有得到堆栈跟踪;而且我似乎没有尝试通过 ldap 进行身份验证。
    猜你喜欢
    • 2020-04-08
    • 1970-01-01
    • 2016-03-27
    • 2020-02-16
    • 2014-06-11
    • 2015-04-17
    • 1970-01-01
    • 2019-10-31
    • 2012-02-18
    相关资源
    最近更新 更多