2010-02-03 138 views
0

我一直在嘗試使用此應用程序來獲得LDAP身份驗證(Apache Roller)。它似乎只是「填充正確的字段並去」,但我仍然試圖對數據庫進行身份驗證(默認身份驗證方法)。Spring安全2.0.5帶有Active Directory的LDAP身份驗證設置

我不明白什麼是告訴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> 

回答

0

我們需要更多的細節來幫助你。如果存在任何錯誤消息,請複製堆棧跟蹤。

我注意到的一件事是在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> 
+0

是的,我在我的研究中看到了您的博客文章。我也嘗試過,但這裏的問題似乎並沒有像映射到ldapAuthProvider那樣在映射中。 我根本沒有得到堆棧跟蹤;我似乎沒有試圖通過ldap進行身份驗證。 – 2010-02-03 19:29:23

相關問題