2014-03-10 08:48:08 -04:00
|
|
|
module Gitlab
|
|
|
|
module LDAP
|
|
|
|
class Access
|
2014-03-14 03:55:50 -04:00
|
|
|
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
|
|
|
|
|
2014-03-10 08:48:08 -04:00
|
|
|
def allowed?(user)
|
2014-05-14 12:32:40 -04:00
|
|
|
if Gitlab::LDAP::Person.find_by_dn(user.extern_uid, adapter)
|
2014-05-14 13:13:06 -04:00
|
|
|
!Gitlab::LDAP::Person.active_directory_disabled?(user.extern_uid, adapter)
|
2014-05-14 12:32:40 -04:00
|
|
|
else
|
|
|
|
false
|
|
|
|
end
|
2014-03-10 08:48:08 -04:00
|
|
|
rescue
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|