# Bug OP-3292 - LDAP authentication does not work with AD-connected LDAP-Server (with fix!)

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-3292

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 6.1.2 |
| Observed in versions |  |
| Sprint |  |
| Backlog bucket |  |
| Bug found in version (deprecated) |  |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

Since the integration of our LDAP server in an AD envirionment, we noticed that our LDAP users were no longer able to login to our OpenProject instance. The OpenProject log says only

    W, [2016-12-02T08:38:13.409035 #1353]  WARN -- : Failed login for 'abcd' from 132.xxx.xxx.xxx at 2016-12-02 07:38:13 UTC

A Wireshark capture of the communication with the LDAP server revealed that the search for the object with cn=abcd does return no objects. But querying the LDAP server with a different LDAP client returns the desired object.  
A comparison of the LDAP search requests showed that the Net::LDAP module of Ruby has a “paged result” flag which is set by default, but can be turned off.  
To disable “paged result”, I modified /opt/openproject/app/models/ldap\_auth\_source.rb:

    def initialize_ldap_con(ldap_user, ldap_password)
      options = { host: host,
                  port: port,
                  force_no_page: true, ### HERE!
                  encryption: (tls ? :simple_tls : nil)
                }
      options.merge!(auth: { method: :simple, username: ldap_user, password: ldap_password }) unless ldap_user.blank? && ldap_password.blank?
      Net::LDAP.new options
    end

After restarting the OpenProject service, our LDAP users were again able to login.
