title: How to debug Gitlab LDAP authentication?
body: <p>I am trying to configure LDAP authentication with gitlab. My configuration is someting like:</p>
  
  <pre><code>ldap:
      enabled: true
      host: 'ldap.example.com'
      base: 'ou=People,o=example.com'
      port: 636
      uid: 'uid'
      method: 'ssl' # "ssl" or "plain"
      bind_dn: 'cn=gitlab,ou=Apps,o=example.com'
      password: 'password'
      allow_username_or_email_login: true
  </code></pre>
  
  <p>I tested it with the following :</p>
  
  <pre><code>ldapsearch  -b "ou=People,o=example.com" -s sub -D "cn=gitlab,ou=Apps,o=example.com" -H ldaps://ldap.example.com:636 -w "password" -x "(uid=myname@example.com)"
  </code></pre>
  
  <p>The line above works, but when I try to log in using LDAP, I always got "invalid credentials".</p>
  
  <p>How can I troubleshoot this and narrow down the root cause f this problem?</p>
  
  <p>Edit 26/09:</p>
  
  <p>Here are some things I found on production.log:</p>
  
  <pre><code>Started GET "/users/sign_in" for 127.0.0.1 at 2013-09-23 17:42:58 -0300
  Processing by Devise::SessionsController#new as HTML
    Rendered devise/sessions/_new_ldap.html.haml (1.7ms)
    Rendered devise/sessions/_new_base.html.haml (1.8ms)
    Rendered devise/sessions/_oauth_providers.html.haml (0.0ms)
    Rendered devise/sessions/new.html.haml within layouts/devise (4.2ms)
    Rendered layouts/_head.html.haml (1.6ms)
    Rendered layouts/_flash.html.haml (0.1ms)
  Completed 200 OK in 9ms (Views: 6.9ms | ActiveRecord: 0.0ms)
  Started POST "/users/auth/ldap/callback" for 127.0.0.1 at 2013-09-23 17:43:00 -0300
  Processing by OmniauthCallbacksController#failure as HTML
    Parameters: {"utf8"=&gt;"â", "authenticity_token"=&gt;"AwqZsVHRqOeZr+GLWWeGM7MyOAdk7cFl8/rZgbVRU+8=", "username"=&gt;"name@example.com", "password"=&gt;"[FILTERED]"}
  Redirected to http://example.com/users/sign_in
  Completed 302 Found in 3ms (ActiveRecord: 0.0ms)
  Started GET "/users/sign_in" for 127.0.0.1 at 2013-09-23 17:43:00 -0300
  Processing by Devise::SessionsController#new as HTML
    Rendered devise/sessions/_new_base.html.haml (2.8ms)
    Rendered devise/sessions/_oauth_providers.html.haml (0.1ms)
    Rendered devise/sessions/new.html.haml within layouts/devise (3.7ms)
    Rendered layouts/_head.html.haml (1.7ms)
    Rendered layouts/_flash.html.haml (0.1ms)
  Completed 200 OK in 9ms (Views: 6.6ms | ActiveRecord: 0.0ms)
  Started GET "/" for 127.0.0.1 at 2013-09-23 18:50:08 -0300
  Processing by DashboardController#show as HTML
  Completed 401 Unauthorized in 1ms
  </code></pre>
  
  <p>Edit: I finally got the answer: a configuration on devise was stripping everyting after the "@". I can't recall the exact name, but I can post as soon as I got access to the machine. I discovered this by adding logs to the ldap oauth login.</p>