I'm trying to acces my application with AD authentication and getting authorization roles from my DB.
this is my configuration
<beans:bean id="activeDirectoryAuthenticationProvider"
class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
<beans:constructor-arg value="mydomain" />
<beans:constructor-arg value="ldap://my URL :389" />
<beans:property name="convertSubErrorCodesToExceptions" value="true"/>
</beans:bean>
I tried to add
<beans:constructor-arg>
<beans:bean class="org.springframework.security.ldap.populator.UserDetailsServiceLdapAuthoritiesPopulator">
<beans:constructor-arg ref="myUserDetailsService"/>
</beans:bean>
</beans:constructor-arg>
but it didn't work. Any help?
Many thanks!!
ActiveDirectoryLdapAuthenticationProvider doesn't use an
LdapAuthoritiesPopulator
(check the API for the constructor).You can use a delegation model, where you wrap the provider and load the authorities separately, before returning a new token containing them:
The class is final mainly due to my rather basic knowledge of Active Directory and the different ways people would want to use it.
Need to set authenticated flag as true in AbstractAuthenticationToken, unless its not take it as success
Lets break this up into 2 parts. First one would be your spring security xml configuration and the second part would be overriding the UserContextMapper that spring security provides.
Your security xml configuration would be
The MyDbAuthorizationFetcher is the class where you would be implementing UserContextMapper class to fetch authorities from DB