title: Java Application with Multiple JAAS Security Realms
body: <p>I was wondering if it was possible to have a Java EE application with multiple JAAS security realms.
  I'm currently developing an application in which some users need to be authenticated with data stored in a database, while other users need to be authenticated through an LDAP bind.</p>
  
  <p>So I created 2 security realms in glassfish 3.1, a JDBC realm and an LDAP realm and configured my web.xml to use the LDAP realm (most users are LDAP).</p>
  
  <p>I then use :</p>
  
  <pre><code>  HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
    request.login(username, password);
  </code></pre>
  
  <p>to authenticate user</p>
  
  <p>is it possible to switch to JDBC realm before calling 'request.login' ?</p>
  
  <p>thanks in advance</p>