Class: GitHub::Ldap::UserSearch::GlobalCatalog

Inherits:
Net::LDAP
  • Object
show all
Defined in:
lib/github/ldap/user_search/active_directory.rb

Constant Summary collapse

STANDARD_GC_PORT =
3268
LDAPS_GC_PORT =
3269

Class Method Summary collapse

Class Method Details

.connection(ldap) ⇒ Object

Returns a connection to the Active Directory Global Catalog

See: technet.microsoft.com/en-us/library/cc728188(v=ws.10).aspx



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/github/ldap/user_search/active_directory.rb', line 32

def self.connection(ldap)
  @global_catalog_instance ||= begin
    netldap = ldap.connection
    # This is ugly, but Net::LDAP doesn't expose encryption or auth
    encryption = netldap.instance_variable_get(:@encryption)
    auth = netldap.instance_variable_get(:@auth)

    new({
      host: ldap.host,
      instrumentation_service: ldap.instrumentation_service,
      port: encryption ? LDAPS_GC_PORT : STANDARD_GC_PORT,
      auth: auth,
      encryption: encryption
    })
  end
end