From 797ac2d60ffbce1506c27e460ed334667d326c64 Mon Sep 17 00:00:00 2001 From: Jan-Willem van der Meer Date: Thu, 9 Oct 2014 08:54:55 +0200 Subject: [PATCH] Make authentication backwards compatible with multiple LDAP servers Note: authentication agains an other server, other then the first still does not work. This will be completed in further MR's --- lib/gitlab/ldap/user.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/gitlab/ldap/user.rb b/lib/gitlab/ldap/user.rb index c8e40a6448..be9392a8d8 100644 --- a/lib/gitlab/ldap/user.rb +++ b/lib/gitlab/ldap/user.rb @@ -45,11 +45,16 @@ module Gitlab def find_by_uid(uid) # LDAP distinguished name is case-insensitive - model.where("provider = ? and lower(extern_uid) = ?", provider, uid.downcase).last + model. + where(provider: [provider, :ldap]). + where('lower(extern_uid) = ?', uid.downcase).last end def provider - 'ldap' + # Note: for backwards compatibility we just get the first provider + # Later on, we should loop through all servers until a successful + # authentication + Gitlab::LDAP::Config.servers.first.provider_name end end