diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-05-14 18:26:58 +0200 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2014-05-14 18:26:58 +0200 |
commit | a754f0b2205d4f09092c8c7c032ad944a229be8f (patch) | |
tree | 70b7146ae4db5ca00553e5a253b08310b7038016 /lib/gitlab/ldap/person.rb | |
parent | d54133b09fdb0b2e589896dc8740bb8d0c99ed54 (diff) | |
download | gitlab-ce-a754f0b2205d4f09092c8c7c032ad944a229be8f.tar.gz |
Add LDAP::Person#ad_disabled?
Check the bit for disabled Active Directory users. The filter is based
on http://ctogonewild.com/2009/09/03/bitmask-searches-in-ldap/ .
Diffstat (limited to 'lib/gitlab/ldap/person.rb')
-rw-r--r-- | lib/gitlab/ldap/person.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/gitlab/ldap/person.rb b/lib/gitlab/ldap/person.rb index 06b17c58f8c..fa57f298e16 100644 --- a/lib/gitlab/ldap/person.rb +++ b/lib/gitlab/ldap/person.rb @@ -1,6 +1,8 @@ module Gitlab module LDAP class Person + AD_USER_DISABLED = Net::LDAP::Filter.ex("userAccountControl:1.2.840.113556.1.4.803", 2) + def self.find_by_uid(uid, adapter=nil) adapter ||= Gitlab::LDAP::Adapter.new adapter.user(config.uid, uid) @@ -11,6 +13,11 @@ module Gitlab adapter.user('dn', dn) end + def self.ad_disabled?(dn, adapter=nil) + adapter ||= Gitlab::LDAP::Adapter.new + adapter.dn_matches_filter?(dn, AD_USER_DISABLED) + end + def initialize(entry) Rails.logger.debug { "Instantiating #{self.class.name} with LDIF:\n#{entry.to_ldif}" } @entry = entry |