From f83934584d809f5648eecaee8ca0d2df3e899e59 Mon Sep 17 00:00:00 2001 From: blackhedd Date: Thu, 31 Aug 2006 12:39:45 +0000 Subject: [PATCH] added Net::LDAP#search_root_dse. --- lib/net/ldap.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/net/ldap.rb b/lib/net/ldap.rb index 1947711..112cfed 100644 --- a/lib/net/ldap.rb +++ b/lib/net/ldap.rb @@ -1000,6 +1000,26 @@ module Net @result == 0 end + + # (Experimental, subject to change). + # Return the rootDSE record from the LDAP server as a Net::LDAP::Entry, or an + # empty Entry if the server doesn't return the record. + #-- + # cf. RFC4512 graf 5.1. + # Note that the rootDSE record we return on success has an empty DN, which is correct. + # On failure, the empty Entry will have a nil DN. There's no real reason for that, + # so it can be changed if desired. + # The funky number-disagreements in the set of attribute names is correct per the RFC. + # + def search_root_dse + rs = search( + :base=>"", + :scope=>SearchScope_BaseObject, + :attributes=>[:namingContexts,:supportedLdapVersion,:altServer,:supportedControl,:supportedExtension,:supportedFeatures,:supportedSASLMechanisms] + ) + (rs and rs.first) or Entry.new + end + end # class LDAP @@ -1122,6 +1142,7 @@ module Net # you won't get more than 1000 results back from a query. # This implementation is kindof clunky and should probably be refactored. # Also, is it my imagination, or are A/Ds the slowest directory servers ever??? + # OpenLDAP newer than version 2.2.0 supports paged searches. # def search args = {} search_filter = (args && args[:filter]) || Filter.eq( "objectclass", "*" )