title: Spring Security 3.1: Active Directory Authentication and local DB Authorization
body: <p>I am using Spring Security 3.1 for Active Directory authentication and a local db for loading the authorities. I have seen similar examples but it is still not clear for me what exactly I should use. My current settings in spring-security.xml is:</p>
  
  <pre><code>  &lt;!-- LDAP server details --&gt;
    &lt;security:authentication-manager&gt;
      &lt;security:authentication-provider ref="ldapActiveDirectoryAuthProvider" /&gt;
    &lt;/security:authentication-manager&gt;
  
  
    &lt;beans:bean id="ldapActiveDirectoryAuthProvider" class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider"&gt;
      &lt;beans:constructor-arg value="${ldap.domain}" /&gt;
      &lt;beans:constructor-arg value="${ldap.url}" /&gt;
      &lt;beans:property name="useAuthenticationRequestCredentials" value="true" /&gt;
      &lt;beans:property name="convertSubErrorCodesToExceptions" value="true" /&gt;
    &lt;/beans:bean&gt;
  </code></pre>
  
  <p>I have a class let's call it: "BookStoreDbAuthPopulator.java". Inside this class, I am calling this method:</p>
  
  <pre><code>    // Load additional authorities and create an Authentication object
      final List&lt;GrantedAuthority&gt; authorities = loadRolesFromDatabaseHere();
  </code></pre>
  
  <p>What is not still clear for me: Which interface should "BookStoreDbAuthPopulator.java" implements in order to add the loaded authorities from db to the UserDetails? "UserDetailsContextMapper" or "GrantedAuthoritiesMapper" or "AuthenticationProvider"?</p>
  
  <p>Based on this solution: <a href="https://stackoverflow.com/questions/9228932/spring-security-3-active-directory-authentication-database-authorization?rq=1">Spring Security 3 Active Directory Authentication, Database Authorization</a>
  "BookStoreDbAuthPopulator.java" should implement "AuthenticationProvider". My doubt is if I should use "BookStoreDbAuthPopulator.java" as a property for "ldapActiveDirectoryAuthProvider" bean?</p>
  
  <p>Many thanks in advance.</p>