Pass LDAP adapter to finders in update_permissions

This commit is contained in:
Jacob Vosmaer
2014-03-14 11:21:50 +01:00
parent 826404a80b
commit 823f89ed40
2 changed files with 5 additions and 4 deletions
+2 -2
View File
@@ -31,13 +31,13 @@ module Gitlab
return true unless Gitlab.config.ldap['group_base'].present?
# Get LDAP user entry
ldap_user = Gitlab::LDAP::Person.find_by_dn(user.extern_uid)
ldap_user = Gitlab::LDAP::Person.find_by_dn(user.extern_uid, adapter)
# Get all GitLab groups with activated LDAP
groups = ::Group.where('ldap_cn IS NOT NULL')
# Get LDAP groups based on cn from GitLab groups
ldap_groups = groups.pluck(:ldap_cn).map { |cn| Gitlab::LDAP::Group.find_by_cn(cn) }
ldap_groups = groups.pluck(:ldap_cn).map { |cn| Gitlab::LDAP::Group.find_by_cn(cn, adapter) }
ldap_groups = ldap_groups.compact.uniq
# Iterate over ldap groups and check user membership
+3 -2
View File
@@ -7,8 +7,9 @@
module Gitlab
module LDAP
class Group
def self.find_by_cn(cn)
Gitlab::LDAP::Adapter.new.group(cn)
def self.find_by_cn(cn, adapter=nil)
adapter ||= Gitlab::LDAP::Adapter.new
adapter.group(cn)
end
def initialize(entry)