From 95d86ea6c30249a43cedd35351aa55ed891369d6 Mon Sep 17 00:00:00 2001 From: blackhedd Date: Wed, 2 May 2007 10:10:19 +0000 Subject: [PATCH] added Net::LDAP#search_subschema_entry --- lib/net/ldap.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/net/ldap.rb b/lib/net/ldap.rb index e4fec28..fd712c3 100644 --- a/lib/net/ldap.rb +++ b/lib/net/ldap.rb @@ -1055,6 +1055,40 @@ module Net (rs and rs.first) or Entry.new end + + # Return the root Subschema record from the LDAP server as a Net::LDAP::Entry, + # or an empty Entry is 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. + #-- + # cf. RFC4512 section 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. + # + def search_subschema_entry + rs = search( + :ignore_server_caps=>true, + :base=>"", + :scope=>SearchScope_BaseObject, + :attributes=>[:subschemaSubentry] + ) + return Entry.new unless (rs and rs.first) + subschema_name = rs.subschemasubentry + return Entry.new unless (subschema_name and subschema_name.first) + + rs = search( + :ignore_server_caps=>true, + :base=>subschema_name, + :scope=>SearchScope_BaseObject, + :filter=>"objectclass=*", + :attributes=>[:objectclasses, :attributetypes] + ) + + (rs and rs.first) or Entry.new + end + + #-- # Convenience method to query server capabilities. # Only do this once per Net::LDAP object.