title: redmine ldap authentication fail
body: <p>I'm not succeeding in LDAP authentication with Redmine. Here follows the description of what I've done:</p>
  
  <p>I've installed Bitnami Redmine on Centos 6.7 and trying to authenticate against AD on MS Windows server 2012.</p>
  
  <pre><code>Environment: Redmine version 3.1.1.stable
  Ruby version 2.0.0-p647 (2015-08-18) [x86_64-linux]
  Rails version 4.2.4
  Environment production
  Database adapter Mysql2
  SCM:
    Subversion 1.6.11
    Git 1.7.1
    Filesystem
  
  Redmine plugins:
    no plugin installed
  </code></pre>
  
  <p>This is my LDAP configuration on Redmine:</p>
  
  <pre><code>Name: geo-AD
  Host: geo-dc.geo.net
  Port 389 LDAPS: No
  User: ldapuser
  DN Base: DC=geo-dc,DC=geo,DC=net
  LDAP filter: (objectClass=*)
  on the fly: yes
  Connection attribute: sAMAccontName
  Name: givenName
  Surname: sn
  Mail: mail
  </code></pre>
  
  <p>The test is working fine, but when I try to authenticate I always get</p>
  
  <blockquote>
    <p>invalid password</p>
  </blockquote>
  
  <p>I traced the authentication phase with Wireshark and I've seen the following:</p>
  
  <p>There is a request from the redmine host to the AD server asking for the following attributes:</p>
  
  <ul>
  <li>dn</li>
  <li>givenName</li>
  <li>sn</li>
  <li>mail</li>
  </ul>
  
  <p>The AD server answer with "no such object" and the authentication stops. I've removed <code>givenName</code>, <code>sn</code> and <code>mail</code> from the LDAP configuration window and the request for DN is still there and cause the failure.</p>
  
  <p>I've checked the AD schema and there is no attribute named "dn".</p>
  
  <p>Any idea why Redmine ask for this during authentication and if there is a way to change this behaviour?</p>
  
  <p>Here follows the LDAP query and LDAP response. 
  <code>192.168.1.244</code> is the Centos server with Redmine, <code>192.168.1.240</code> is MS Server 2012 with AD.</p>
  
  <pre><code>No.     Time           Source                Destination           Protocol Length Info
  
  72 28.269126319   192.168.1.244         192.168.1.240         LDAP     237    searchRequest(2) "DC=geo-dc,DC=geo,DC=net" wholeSubtree 
  </code></pre>
  
  <p>Frame 72: 237 bytes on wire (1896 bits), 237 bytes captured (1896 bits) on interface 0   </p>
  
  <p>Lightweight Directory Access Protocol</p>
  
  <pre><code>LDAPMessage searchRequest(2) "DC=geo-dc,DC=geo,DC=net" wholeSubtree
  
      messageID: 2
  
      protocolOp: searchRequest (3)
  
          searchRequest
  
              baseObject: DC=geo-dc,DC=geo,DC=net
  
              scope: wholeSubtree (2)
  
              derefAliases: neverDerefAliases (0)
  
              sizeLimit: 0
  
              timeLimit: 0
  
              typesOnly: False
  
              Filter: (&amp;(&amp;(objectClass=*)(objectClass=*))
  (sAMAccountName=mlavagna))
  
                  filter: and (0)
  
                      and: (&amp;(&amp;(objectClass=*)(objectClass=*))
  (sAMAccountName=mlavagna))
  
                          and: 3 items
  
                              Filter: (objectClass=*)
  
                                  and item: present (7)
  
                                      present: objectClass
  
                              Filter: (objectClass=*)
  
                                  and item: present (7)
  
                                      present: objectClass
  
                              Filter: (sAMAccountName=mlavagna)
  
                                  and item: equalityMatch (3)
  
                                      equalityMatch
  
                                          attributeDesc: sAMAccountName
  
                                          assertionValue: mlavagna
  
              attributes: 4 items
  
                  AttributeDescription: dn
  
                  AttributeDescription: givenName
  
                  AttributeDescription: sn
  
                  AttributeDescription: mail
  
      [Response In: 73]
  
      controls: 1 item
  
          Control
  
              controlType: 1.2.840.113556.1.4.319 (pagedResultsControl)
  
              criticality: False
  
              SearchControlValue
  
                  size: 126
  
                  cookie: &lt;MISSING&gt;
  </code></pre>
  
  <p>No.     Time           Source                Destination               Protocol</p>
  
  <p>74 28.269493413   192.168.1.244         192.168.1.240         TCP      </p>
  
  <p>Lightweight Directory Access Protocol</p>
  
  <pre><code>LDAPMessage searchResDone(2) noSuchObject (0000208D: NameErr: DSID-03100238, problem 2001 (NO_OBJECT), data 0, best match of:
  
  'DC=geo,DC=net'
  
  ) [0 results]
  
      messageID: 2
  
      protocolOp: searchResDone (5)
  
          searchResDone
  
              resultCode: noSuchObject (32)
  
              matchedDN: DC=geo,DC=net
  
              errorMessage: 0000208D: NameErr: DSID-03100238, problem 2001 
  (NO_OBJECT), data 0, best match of:\n\t'DC=geo,DC=net'\n
  
      [Response To: 72]
  
      [Time: 0.000264030 seconds]
  </code></pre>