Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions lib/ldap_fluff/posix_member_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,35 @@ 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
# This group will check all the groups and will match the user. MemberOf plugin
# it's not required for this operation, once this plugin it's optional in ldap.
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]

search_filter = Net::LDAP::Filter.eq('objectClass', 'groupOfNames')
results_attr = ["cn", "member"]

ldap.search(:filter => search_filter, :attributes => results_attr).each do |grp_info|

grp_info[:member].each do |login|
only_uid = login.split(',')[0].split('=')[1]

if only_uid.include?(uid)
groups << grp_info[:cn]
end
end
end

if groups.length > 0
groups.flatten!
else
groups = []
end
groups
end




def times_in_groups(uid, gids, all)
filters = []
gids.each do |cn|
Expand Down