Announcement Announcement Module
Collapse
No announcement yet.
LDAP authentication: how to set PasswordAttributeName? Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • LDAP authentication: how to set PasswordAttributeName?

    Hi,

    I am trying to do LDAP authentication, but the password attribute in LDAP is "userPassword".

    How do I configure this in spring security?

    I was trying to provide a UserDetailMapper as in the following codes, but then I realized that the setUserDetailsMapper is removed from AbstractLDAPAuthenticator, which BindAuthenticator inheres.

    Many thanks in advance,
    Yee

    ---------------------------------------------------------------------------------

    Code:
    <beans:bean id="userDetailsMapper" 
    class="org.springframework.security.userdetails.ldap.LdapUserDetailsMapper">
    	<beans:property name="passwordAttributeName">
    		<beans:value>userPassword</beans:value>
    	</beans:property>
    </beans:bean>
    
    <beans:bean id="bindAuthenticator" 
    class="org.springframework.security.providers.ldap.authenticator.BindAuthenticator">
    	<beans:constructor-arg ref="myLdapServer" />
    	<beans:property name="userDnPatterns">
    		<beans:list>
    			<beans:value>cn={0},o=SSM</beans:value>
    		</beans:list>
    	</beans:property>
    	<beans:property name="userDetailsMapper" ref="userDetailsMapper" />
    </beans:bean>
    
    <beans:bean id="adminLdapAuthProvider"
    		class="org.springframework.security.providers.ldap.LdapAuthenticationProvider">
    	<custom-authentication-provider />
    	<beans:constructor-arg ref="bindAuthenticator" />
    	<beans:constructor-arg>
    		<beans:bean class="mypackage.MyAuthoritiesPopulator" />
    		</beans:constructor-arg>
    </beans:bean>

  • #2
    The UserDetailsContextMapper is set on the authentication provider. Take a look at the LDAP chapter in the manual.

    Comment

    Working...
    X