Skip to content

Commit

Permalink
Use map to transform values in find_user_groups
Browse files Browse the repository at this point in the history
This simplifies the code by using more a expressive method, removing the
need for helper variables.
  • Loading branch information
ekohl authored and adamruzicka committed Aug 29, 2024
1 parent 8d9639c commit 3d11c47
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/ldap_fluff/posix_member_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ def find_user(uid, base_dn = @base)
# return an ldap user with groups attached
# 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),
:base => @group_base, :attributes => ["cn"]
).each do |entry|
groups << entry[:cn][0]
end
groups
).map { |entry| entry[:cn][0] }
end

class UIDNotFoundException < LdapFluff::Error
Expand Down

0 comments on commit 3d11c47

Please sign in to comment.