title: Symfony2: user/authentication provider; password check
body: <p>Out of the documentation of Symfony, I understand how the user provider and authentication provider should work. I try to implement my own user and/or authentication Provider. What i did not yet get completely, is how to compare/where to check the password within this System. </p>
  
  <p>In the documentation [1] I can see, that the user provider shall return a user object, if the user even exists. But then, I can see, that if the user has been found, the user is in this example returned with</p>
  
  <pre><code> return new WebserviceUser($username, $password, $salt, $roles);
  </code></pre>
  
  <ol>
  <li>question is: Why is the user object returned with the password here. </li>
  <li>question: How to retrieve the password in this class? Isn't this the task of the authentication provider? If so, how to check the password there?</li>
  </ol>
  
  <p>There is surely a use case where this model makes sense, but for the time being, I do not see it. Maybe someone here has the background to explain this to me.</p>
  
  <p>Background: I want to use LDAP for authentication. So my first approach would be to create a user provider who checks anonymously if the user exists through a ldap search and if so, tries to authenticate him. The thing is, that I cannot return a user object with password (but also other attributes which I only get when the user is already authenticated). The user will then be stored/cached in a local DB where user specific settings and attributes will also be saved.</p>
  
  <p>[1] <a href="http://symfony.com/doc/current/cookbook/security/custom_provider.html#create-a-user-provider" rel="nofollow">http://symfony.com/doc/current/cookbook/security/custom_provider.html#create-a-user-provider</a></p>