title: Check login on User with multiple property in Symfony2
body: <p>I'm building a multi-tenant application in Symfony2.  For the secure "admin" area I have a custom entity provider (see: <a href="http://symfony.com/doc/current/cookbook/security/entity_provider.html" rel="nofollow">http://symfony.com/doc/current/cookbook/security/entity_provider.html</a>) </p>
  
  <p>However, it seems that Symfony2 only supports checking the entity on a single property.</p>
  
  <pre><code>my_entity_provider:
              entity:
                  class:              SecurityBundle:User
                  property:           email
  </code></pre>
  
  <p>However, in my app a single User can have multiple accounts with the same email address. What I need is to also check for a tenant ID property when logging in.</p>
  
  <pre><code>my_entity_provider:
              entity:
                  class:              SecurityBundle:User
                  property:           email, tenantID
  </code></pre>
  
  <p>I'm not sure how to accomplish this in Symfony2.  I've been able to override the loadUsername method when creating a new User, but this isn't used by the login_check in Symfony2 security (and it is really ugly).</p>
  
  <pre><code> public function loadUserByUsername($username)
      {
          /* we create a concatenated string in the  User entity to pass both
          the email and tenantId values as the "username" */
          $user_parts = explode("|", $username); 
  
          $q = $this-&gt;createQueryBuilder('u')
              -&gt;where('u.tenantId = :tenantid AND u.email = :email')
              -&gt;setParameter('tenantID', $user_parts[1])
              -&gt;setParameter('email', $user_parts[0])
              -&gt;getQuery();
  
          try { 
              $user = $q-&gt;getSingleResult();
  
          } catch (NoResultException $e) {
              throw new UsernameNotFoundException(sprintf('Unable to find an active User object identified by "%s".', $username), null, 0, $e);
          }
  
          return $user;
      }
  </code></pre>
  
  <p>Any guidance on implementing a custom security provider with multiple properties?  Thanks!</p>