Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9f48809

Browse files
committed
Add Classic members search strategy
1 parent 19b60bd commit 9f48809

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

lib/github/ldap/members.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'github/ldap/members/classic'
12
require 'github/ldap/members/recursive'
23

34
module GitHub
@@ -13,6 +14,7 @@ class Ldap
1314
module Members
1415
# Internal: Mapping of strategy name to class.
1516
STRATEGIES = {
17+
:classic => GitHub::Ldap::Members::Classic,
1618
:recursive => GitHub::Ldap::Members::Recursive
1719
}
1820
end

lib/github/ldap/members/classic.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module GitHub
2+
class Ldap
3+
module Members
4+
# Look up group members using the existing `Group#members` and
5+
# `Group#subgroups` API.
6+
class Classic
7+
# Internal: The GitHub::Ldap object to search domains with.
8+
attr_reader :ldap
9+
10+
# Public: Instantiate new search strategy.
11+
#
12+
# - ldap: GitHub::Ldap object
13+
# - options: Hash of options (unused)
14+
def initialize(ldap, options = {})
15+
@ldap = ldap
16+
@options = options
17+
end
18+
19+
# Public: Performs search for group members, including groups and
20+
# members of subgroups recursively.
21+
#
22+
# Returns Array of Net::LDAP::Entry objects.
23+
def perform(group_entry)
24+
group = ldap.load_group(group_entry)
25+
group.members + group.subgroups
26+
end
27+
end
28+
end
29+
end
30+
end

0 commit comments

Comments
 (0)