2010-02-03 75 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

相关问题