我想使Spring Security 3.05與修改後的UserDetailsContextMapper一起工作,以便我可以從LDAP中獲得更多信息他們的方式我需要,這似乎相當簡單的任務,但沒有成功。春季安全與LDAP和自定義UserDetailsContextMapper
我已經配置Spring Security的使用LDAP認證有以下豆:
<bean id="contextSource"
class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<constructor-arg value="ldaps://192.168.1.102:636" />
<property name="userDn" value="manager" />
<property name="password" value="password" />
</bean>
<bean id="ldapAuthProvider"
class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<constructor-arg>
<bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
<constructor-arg ref="contextSource" />
<property name="userSearch">
<bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
<constructor-arg index="0" value="" />
<constructor-arg index="1" value="(mail={0})" />
<constructor-arg index="2" ref="contextSource" />
</bean>
</property>
</bean>
</constructor-arg>
<property name="userDetailsContextMapper" ref="myContextMapper" />
</bean>
然而,即使我已經定義myContextMapper
爲:
<bean id="myContextMapper" class="com.mypackage.MyLDAPUserDetailsMapper">
<property name="rolePrefix" value="TEST_PREFIX" />
</bean>
這是行不通的。這意味着自定義映射器被忽略(我沒有得到任何調試輸出)。
p.s. applicationContext-security.xml可以在下面看到,除了被忽略的自定義UserDetailsMapper,認證和角色分配工作正常。
<authentication-manager>
<ldap-authentication-provider server-ref="contextSource"/>
</authentication-manager>
謝謝,那是對的! – nvrs 2011-03-08 08:25:27
關於如何配置ldap-authentication-provider的所述用戶詳細信息類屬性,您會對此有更多的瞭解嗎?謝謝! – dade 2014-09-22 11:14:04
事情是我正在使用 來配置身份驗證提供程序,並且似乎沒有user-context-mapper-ref。那麼你如何繼續建議呢?謝謝! –
dade
2014-09-22 11:27:36