@@ -9,14 +9,17 @@ class Recursive
9
9
include Filter
10
10
11
11
DEFAULT_MAX_DEPTH = 9
12
- ATTRS = %w( member uniqueMember memberUid )
12
+ DEFAULT_ATTRS = %w( member uniqueMember memberUid )
13
13
14
14
# Internal: The GitHub::Ldap object to search domains with.
15
15
attr_reader :ldap
16
16
17
17
# Internal: The maximum depth to search for members.
18
18
attr_reader :depth
19
19
20
+ # Internal: The attributes to search for.
21
+ attr_reader :attrs
22
+
20
23
# Public: Instantiate new search strategy.
21
24
#
22
25
# - ldap: GitHub::Ldap object
@@ -25,6 +28,7 @@ def initialize(ldap, options = {})
25
28
@ldap = ldap
26
29
@options = options
27
30
@depth = options [ :depth ] || DEFAULT_MAX_DEPTH
31
+ @attrs = Array ( options [ :attrs ] ) . concat DEFAULT_ATTRS
28
32
end
29
33
30
34
# Public: Performs search for group members, including groups and
@@ -95,7 +99,7 @@ def member_entries(entry)
95
99
# Returns an Array of Net::LDAP::Entry objects.
96
100
def entries_by_dn ( members )
97
101
members . map do |dn |
98
- ldap . domain ( dn ) . bind ( attributes : ATTRS )
102
+ ldap . domain ( dn ) . bind ( attributes : attrs )
99
103
end . compact
100
104
end
101
105
private :entries_by_dn
@@ -106,7 +110,7 @@ def entries_by_dn(members)
106
110
def entries_by_uid ( members )
107
111
filter = members . map { |uid | Net ::LDAP ::Filter . eq ( ldap . uid , uid ) } . reduce ( :| )
108
112
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 )
110
114
end . compact
111
115
end
112
116
private :entries_by_uid
0 commit comments