Skip to content

Commit

Permalink
POSIX group_list(login) uses group base DN
Browse files Browse the repository at this point in the history
This commit changes the underlying methods for group_list so
that they start using the group base DN to search for groups,
as it was using the global DN before.
  • Loading branch information
dLobatog committed Jan 10, 2017
1 parent be834ad commit 1b2fea9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/ldap_fluff/posix_member_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def initialize(ldap, config)
super
end

def find_user(uid)
user = @ldap.search(:filter => name_filter(uid), :base => @base)
def find_user(uid, base_dn = @base)
user = @ldap.search(:filter => name_filter(uid), :base => base_dn)
raise UIDNotFoundException if (user.nil? || user.empty?)
user
end
Expand All @@ -18,7 +18,8 @@ def find_user(uid)
# note : this method is not particularly fast for large ldap systems
def find_user_groups(uid)
groups = []
@ldap.search(:filter => Net::LDAP::Filter.eq('memberuid', uid)).each do |entry|
@ldap.search(:filter => Net::LDAP::Filter.eq('memberuid', uid),
:base => @group_base).each do |entry|
groups << entry[:cn][0]
end
groups
Expand Down
3 changes: 2 additions & 1 deletion test/posix_member_services_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def test_find_user

def test_find_user_groups
user = posix_user_payload
@ldap.expect(:search, user, [:filter => @ms.name_filter('john')])
@ldap.expect(:search, user, [:filter => @ms.name_filter('john'),
:base => config.group_base])
@ms.ldap = @ldap
assert_equal ['bros'], @ms.find_user_groups('john')
@ldap.verify
Expand Down

0 comments on commit 1b2fea9

Please sign in to comment.