@@ -9,14 +9,17 @@ class Recursive
99 include Filter
1010
1111 DEFAULT_MAX_DEPTH = 9
12- ATTRS = %w( member uniqueMember memberUid )
12+ DEFAULT_ATTRS = %w( member uniqueMember memberUid )
1313
1414 # Internal: The GitHub::Ldap object to search domains with.
1515 attr_reader :ldap
1616
1717 # Internal: The maximum depth to search for members.
1818 attr_reader :depth
1919
20+ # Internal: The attributes to search for.
21+ attr_reader :attrs
22+
2023 # Public: Instantiate new search strategy.
2124 #
2225 # - ldap: GitHub::Ldap object
@@ -25,6 +28,7 @@ def initialize(ldap, options = {})
2528 @ldap = ldap
2629 @options = options
2730 @depth = options [ :depth ] || DEFAULT_MAX_DEPTH
31+ @attrs = Array ( options [ :attrs ] ) . concat DEFAULT_ATTRS
2832 end
2933
3034 # Public: Performs search for group members, including groups and
@@ -95,7 +99,7 @@ def member_entries(entry)
9599 # Returns an Array of Net::LDAP::Entry objects.
96100 def entries_by_dn ( members )
97101 members . map do |dn |
98- ldap . domain ( dn ) . bind ( attributes : ATTRS )
102+ ldap . domain ( dn ) . bind ( attributes : attrs )
99103 end . compact
100104 end
101105 private :entries_by_dn
@@ -106,7 +110,7 @@ def entries_by_dn(members)
106110 def entries_by_uid ( members )
107111 filter = members . map { |uid | Net ::LDAP ::Filter . eq ( ldap . uid , uid ) } . reduce ( :| )
108112 domains . each_with_object ( [ ] ) do |domain , entries |
109- entries . concat domain . search ( filter : filter , attributes : ATTRS )
113+ entries . concat domain . search ( filter : filter , attributes : attrs )
110114 end . compact
111115 end
112116 private :entries_by_uid
0 commit comments