Skip to content

Commit 95d86ea

Browse files
author
blackhedd
committed
added Net::LDAP#search_subschema_entry
1 parent 55c6d2e commit 95d86ea

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

lib/net/ldap.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,40 @@ def search_root_dse
10551055
(rs and rs.first) or Entry.new
10561056
end
10571057

1058+
1059+
# Return the root Subschema record from the LDAP server as a Net::LDAP::Entry,
1060+
# or an empty Entry is the server doesn't return the record. On success, the
1061+
# Net::LDAP::Entry returned from this call will have the attributes :dn,
1062+
# :objectclasses, and :attributetypes.
1063+
#--
1064+
# cf. RFC4512 section 4.
1065+
# The :dn attribute in the returned Entry is the subschema name as returned from
1066+
# the server.
1067+
# Set :ignore_server_caps, see the notes in search_root_dse.
1068+
#
1069+
def search_subschema_entry
1070+
rs = search(
1071+
:ignore_server_caps=>true,
1072+
:base=>"",
1073+
:scope=>SearchScope_BaseObject,
1074+
:attributes=>[:subschemaSubentry]
1075+
)
1076+
return Entry.new unless (rs and rs.first)
1077+
subschema_name = rs.subschemasubentry
1078+
return Entry.new unless (subschema_name and subschema_name.first)
1079+
1080+
rs = search(
1081+
:ignore_server_caps=>true,
1082+
:base=>subschema_name,
1083+
:scope=>SearchScope_BaseObject,
1084+
:filter=>"objectclass=*",
1085+
:attributes=>[:objectclasses, :attributetypes]
1086+
)
1087+
1088+
(rs and rs.first) or Entry.new
1089+
end
1090+
1091+
10581092
#--
10591093
# Convenience method to query server capabilities.
10601094
# Only do this once per Net::LDAP object.

0 commit comments

Comments
 (0)