title: Using both LDAP and DB authentication with Spring Security
body: <p>I have an application that is used by two sets of users-internal users for the the company and external customers.
  I have to perform authentication for both sets of users.The application is to be built using Spring Security.
  For internal user, LDAP AD authentication needs to done.And for external users, authentication is to be done from database. I am stuck here. </p>
  
  <p>How can I use both types of authentication? The users can be differentiated based on their email IDs - for example, internal users will all have an email id ending with @company.com.</p>
  
  <ol>
  <li><p>In spring security configuration, can it done like this?-</p>
  
  <pre><code>&lt;authentication-manager&gt;
          &lt;authentication-provider&gt;
              &lt;ldap-authentication-provider....&gt;
              &lt;db-authentication-provider......&gt;  
          &lt;/authentication-provider&gt;
  &lt;authentication-manager&gt;
  </code></pre></li>
  <li><p>Then should I write a filter (that comes before spring security's filter) that selects users based on their login email IDs and directs them to the correct authentication manager? Is this redirection possible to be done here?</p></li>
  </ol>
  
  <p>I am new to this.Thanks in advance.</p>