I am trying to make Spring Security 3.05 work with a modified UserDetailsContextMapper so that I can get some more information from LDAP, as I need it, a task that seems pretty simple, but was not successful.
I configured Spring Security to use LDAP authentication with the following beans:
<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>
However, although I have defined myContextMapper as:
<bean id="myContextMapper" class="com.mypackage.MyLDAPUserDetailsMapper"> <property name="rolePrefix" value="TEST_PREFIX" /> </bean>
he does not work. this means that the user mapper is ignored (I don't get any debug output at all).
ps applicationContext-security.xml can be seen below, and besides the custom UserDetailsMapper, which was ignored, authentication and role assignment work fine.
<authentication-manager> <ldap-authentication-provider server-ref="contextSource"/> </authentication-manager>
source share