Class: LDAP::Conn

Inherits:
Object
  • Object
show all
Defined in:
lib/ldap/schema.rb

Instance Method Summary collapse

Instance Method Details

#root_dse(attrs = nil, sec = 0, usec = 0) ⇒ Object

Fetch the root DSE (DSA-specific Entry) for the connection. DSA stands for Directory System Agent and simply refers to the LDAP server you are using.

attrs, if given, is an array of attributes that should be returned from the server. The default list is subschemaSubentry, namingContexts, monitorContext, altServer, supportedControl, supportedExtension, supportedFeatures, supportedSASLMechanisms and supportedLDAPVersion.

sec and usec can be used to specify a time-out for the search in seconds and microseconds, respectively.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/ldap/schema.rb', line 114

def root_dse(attrs = nil, sec = 0, usec = 0)
  attrs ||= [
    'subschemaSubentry',
    'namingContexts',
    'monitorContext',
    'altServer',
    'supportedControl',
    'supportedExtension',
    'supportedFeatures',
    'supportedSASLMechanisms',
    'supportedLDAPVersion',
  ]

  entries = search2('', LDAP_SCOPE_BASE, '(objectClass=*)',
    attrs, false, sec, usec)

  return entries
end

#schema(base = nil, attrs = nil, sec = 0, usec = 0) ⇒ Object

Fetch the schema data for the connection.

If base is given, it gives the base DN for the search. attrs, if given, is an array of attributes that should be returned from the server. The default list is objectClasses, attributeTypes, matchingRules, matchingRuleUse, dITStructureRules, dITContentRules, nameForms and ldapSyntaxes.

sec and usec can be used to specify a time-out for the search in seconds and microseconds, respectively.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/ldap/schema.rb', line 82

def schema(base = nil, attrs = nil, sec = 0, usec = 0)
  attrs ||= [
    'objectClasses',
    'attributeTypes',
    'matchingRules',
    'matchingRuleUse',
    'dITStructureRules',
    'dITContentRules',
    'nameForms',
    'ldapSyntaxes',
  ]
  base ||= root_dse(['subschemaSubentry'], sec, usec)[0]['subschemaSubentry'][0]
  base ||= 'cn=schema'
  entries = search2(base, LDAP_SCOPE_BASE, '(objectClass=subschema)',
    attrs, false, sec, usec)

  return Schema.new(entries[0])
end