Class: GitHub::Ldap::ReferralChaser
- Inherits:
-
Object
- Object
- GitHub::Ldap::ReferralChaser
- Defined in:
- lib/github/ldap/referral_chaser.rb
Overview
This class adds referral chasing capability to a GitHub::Ldap connection.
See: technet.microsoft.com/en-us/library/cc978014.aspx
http://www.umich.edu/~dirsvcs/ldap/doc/other/ldap-ref.html
Defined Under Namespace
Classes: Referral
Instance Method Summary collapse
-
#initialize(connection) ⇒ ReferralChaser
constructor
Public - Creates a ReferralChaser that decorates an instance of GitHub::Ldap with additional functionality to the #search method, allowing it to chase any referral entries and aggregate the results into a single response.
-
#search(options) ⇒ Object
Public - Search the domain controller represented by this instance’s connection.
Constructor Details
#initialize(connection) ⇒ ReferralChaser
Public - Creates a ReferralChaser that decorates an instance of GitHub::Ldap with additional functionality to the #search method, allowing it to chase any referral entries and aggregate the results into a single response.
connection - The instance of GitHub::Ldap to use for searching. Will use the connection’s authentication, (admin_user and admin_password) as credentials for connecting to referred domain controllers.
18 19 20 21 22 23 |
# File 'lib/github/ldap/referral_chaser.rb', line 18 def initialize(connection) @connection = connection @admin_user = connection.admin_user @admin_password = connection.admin_password @port = connection.port end |
Instance Method Details
#search(options) ⇒ Object
Public - Search the domain controller represented by this instance’s connection. If a referral is returned, search only one of the domain controllers indicated by the referral entries, per RFC 4511 (tools.ietf.org/html/rfc4511):
“If the client wishes to progress the operation, it contacts one of
the supported services found in the referral. If multiple URIs are
present, the client assumes that any supported URI may be used to
progress the operation."
options - is a hash with the same options that Net::LDAP::Connection#search supports.
Referral searches will use the given options, but will replace options[:base]
with the referral URL's base search dn.
Does not take a block argument as GitHub::Ldap and Net::LDAP::Connection#search do.
Will not recursively follow any subsequent referrals.
Returns an Array of Net::LDAP::Entry.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/github/ldap/referral_chaser.rb', line 43 def search() search_results = [] referral_entries = [] search_results = connection.search() do |entry| if entry && entry[:search_referrals] referral_entries << entry end end unless referral_entries.empty? entry = referral_entries.first referral_string = entry[:search_referrals].first if GitHub::Ldap::URL.valid?(referral_string) referral = Referral.new(referral_string, admin_user, admin_password, port) search_results = referral.search() end end Array(search_results) end |