Method: Net::LDAP#search_subschema_entry
- Defined in:
- lib/net/ldap.rb
permalink #search_subschema_entry ⇒ Object
Return the root Subschema record from the LDAP server as a Net::LDAP::Entry, or an empty Entry if the server doesn’t return the record. On success, the Net::LDAP::Entry returned from this call will have the attributes :dn, :objectclasses, and :attributetypes. If there is an error, call #get_operation_result for more information.
ldap = Net::LDAP.new
ldap.host = "your.ldap.host"
ldap.auth "your-user-dn", "your-psw"
subschema_entry = ldap.search_subschema_entry
subschema_entry.attributetypes.each do |attrtype|
# your code
end
subschema_entry.objectclasses.each do |attrtype|
# your code
end
– cf. RFC4512 section 4, particulary graff 4.4. The :dn attribute in the returned Entry is the subschema name as returned from the server. Set :ignore_server_caps, see the notes in search_root_dse. ++
1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 |
# File 'lib/net/ldap.rb', line 1256 def search_subschema_entry rs = search(:ignore_server_caps => true, :base => "", :scope => SearchScope_BaseObject, :attributes => [:subschemaSubentry]) return Net::LDAP::Entry.new unless (rs and rs.first) subschema_name = rs.first.subschemasubentry return Net::LDAP::Entry.new unless (subschema_name and subschema_name.first) rs = search(:ignore_server_caps => true, :base => subschema_name.first, :scope => SearchScope_BaseObject, :filter => "objectclass=subschema", :attributes => [:objectclasses, :attributetypes]) (rs and rs.first) or Net::LDAP::Entry.new end |