From 3d11c47169ab89436a025f7bd1728fcc868feab2 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Thu, 29 Aug 2024 16:07:02 +0200 Subject: [PATCH] Use map to transform values in find_user_groups This simplifies the code by using more a expressive method, removing the need for helper variables. --- lib/ldap_fluff/posix_member_service.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/ldap_fluff/posix_member_service.rb b/lib/ldap_fluff/posix_member_service.rb index 22bbc2c..0be40c4 100644 --- a/lib/ldap_fluff/posix_member_service.rb +++ b/lib/ldap_fluff/posix_member_service.rb @@ -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