title: Symfony authentifcation through LDAP doesn't work with login form
body: <p>I've some trouble with LDAP authentication with a custom login form, however it works perfectly with the http_basic_ldap so it's not an error of LDAP.</p>
  
  <p>My files :
  <strong>app/config/security.yml</strong></p>
  
  <pre><code>security:
  providers:
      my_ldap:
          ldap:
              service: ldap
              base_dn: ou=People,dc=insa-toulouse,dc=fr
              search_dn: ~
              search_password: ~
              default_roles: ROLE_USER
              uid_key: uid
  
  firewalls:
      dev:
          pattern: ^/(_(profiler|wdt)|css|images|js)/
          security: false
  
      login_firewall:
          pattern:   ^/login$
          anonymous: ~
      main:
          logout:
              path: /logout
          form_login_ldap:
              login_path: login
              check_path: login_check
              service: ldap
              dn_string: 'uid={username},ou=People,dc=insa-toulouse,dc=fr'
          #anonymous: true
          #http_basic_ldap:
          #    service: ldap
          #    dn_string: 'uid={username},ou=People,dc=insa-toulouse,dc=fr'
      default:
          anonymous: ~
  </code></pre>
  
  <p>Note that commented http basic works perfectly !</p>
  
  <p><strong>app/config/services.yml</strong></p>
  
  <pre><code>services:
  ldap:  
      class: Symfony\Component\Ldap\LdapClient
      arguments:
          - srv-ldap
  </code></pre>
  
  <p><strong>Controller/SecurityController.php</strong></p>
  
  <pre><code>        &lt;?php
  
      namespace ClubInfo\PizzaBundle\Controller;
  
      use Symfony\Bundle\FrameworkBundle\Controller\Controller;
      use Symfony\Component\HttpFoundation\Request;
      use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  
      class SecurityController extends Controller
      {
              /**
               * @Route("/login", name="login")
               */
              public function loginAction(Request $request)
              {
                      $authenticationUtils = $this-&gt;get('security.authentication_utils');
  
                      // get the login error if there is one
                      $error = $authenticationUtils-&gt;getLastAuthenticationError();
  
                      // last username entered by the user
                      $lastUsername = $authenticationUtils-&gt;getLastUsername();
  
                      return $this-&gt;render(
                              'ClubInfoPizzaBundle:security:login.html.twig',
                              array(
                                      // last username entered by the user
                                      'last_username' =&gt; $lastUsername,
                                      'error'         =&gt; $error,
                              )
                      );
              }
      }
  </code></pre>
  
  <p>and <strong>Resources/views/security/login.html.twig</strong></p>
  
  <pre><code>{% if error %}
      &lt;div&gt;{{ error.messageKey|trans(error.messageData, 'security') }}&lt;/div&gt;
  {% endif %}
  
  &lt;form action="{{ path('login') }}" method="post"&gt;
      &lt;label for="username"&gt;Username:&lt;/label&gt;
      &lt;input type="text" id="username" name="_username" value="{{ last_username }}" /&gt;
  
      &lt;label for="password"&gt;Password:&lt;/label&gt;
      &lt;input type="password" id="password" name="_password" /&gt;
  
      {#
          If you want to control the URL the user
          is redirected to on success (more details below)
          &lt;input type="hidden" name="_target_path" value="/account" /&gt;
      #}
  
      &lt;button type="submit"&gt;login&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Thank you for answers ;)</p>