Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Security 3.1 using Active Directory

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?

like image 596
A C S Avatar asked Mar 08 '12 08:03

A C S


1 Answers

<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.

like image 175
pap Avatar answered Sep 18 '22 23:09

pap