6
votes

I'm trying to secure my Spring 3.1 web app with Spring Security 3.1, and I need to use Active Directory for user authentication. However, I cant seem to find the complete configuration steps. I tried different bits of suggestions but they didn't work for me.

What are the complete steps of configuration to enable a Spring 3.1 web app to use Spring Security 3.1 with Active Directory?

1

1 Answers

5
votes
<beans:bean id="adAuthProvider" class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
    <beans:constructor-arg value="[your domain]" />
    <beans:constructor-arg value="ldap://[your AD server]:389" />
    <beans:property name="userDetailsContextMapper">
        <beans:bean class="[your user-details context mapper]" />
    </beans:property>
</beans:bean>
<authentication-manager alias="authenticationManager">

    <authentication-provider ref="adAuthProvider" />
</authentication-manager>

If you need to provide custom logic for mapping user and authorities from the AD entry, you can implement your own UserDetailsContextMapper implementation and specify it in the userDetailsContextMapper property on the adAuthProvider bean.