Commit 56df3dbf authored by Jacob Vosmaer's avatar Jacob Vosmaer

Add Gitlab::LDAP::Access.open

This new method wraps Gitlab::LDAP::Adapter.open to enable connection
reuse.
parent af53aa90
module Gitlab
module LDAP
class Access
attr_reader :adapter
def self.open(&block)
Gitlab::LDAP::Adapter.open do |adapter|
block.call(self.new(adapter))
end
end
def initialize(adapter=nil)
@adapter = adapter
end
def allowed?(user)
!!Gitlab::LDAP::Person.find_by_dn(user.extern_uid)
!!Gitlab::LDAP::Person.find_by_dn(user.extern_uid, adapter)
rescue
false
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment