Class: LdapFluff::NetIQ::MemberService
- Inherits:
-
Posix::MemberService
- Object
- GenericMemberService
- Posix::MemberService
- LdapFluff::NetIQ::MemberService
- Defined in:
- lib/ldap_fluff/netiq_member_service.rb
Overview
handles the naughty bits of posix ldap
Instance Attribute Summary
Attributes inherited from GenericMemberService
Instance Method Summary collapse
- #find_by_dn(search_dn) ⇒ Object
-
#find_user_groups(uid) ⇒ Object
return an ldap user with groups attached note : this method is not particularly fast for large ldap systems.
- #get_logins(userlist) ⇒ Object
-
#initialize(ldap, config) ⇒ MemberService
constructor
A new instance of MemberService.
Methods inherited from Posix::MemberService
Methods inherited from GenericMemberService
#find_group, #find_user, #get_groups, #get_login_from_entry, #get_netgroup_users, #group_filter, #name_filter
Constructor Details
#initialize(ldap, config) ⇒ MemberService
Returns a new instance of MemberService.
5 6 7 8 9 |
# File 'lib/ldap_fluff/netiq_member_service.rb', line 5 def initialize(ldap, config) super # set default after super, because Posix' initialize would overwrite it otherwise @attr_login = (config.attr_login || 'uid') end |
Instance Method Details
#find_by_dn(search_dn) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/ldap_fluff/netiq_member_service.rb', line 11 def find_by_dn(search_dn) entry, base = search_dn.split(/(?<!\\),/, 2) _entry_attr, entry_value = entry.split('=', 2) entry_value = entry_value.gsub('\,', ',') user = @ldap.search(:filter => name_filter(entry_value, 'workforceid'), :base => base) raise self.class::UIDNotFoundException if (user.nil? || user.empty?) user end |
#find_user_groups(uid) ⇒ Object
return an ldap user with groups attached note : this method is not particularly fast for large ldap systems
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ldap_fluff/netiq_member_service.rb', line 28 def find_user_groups(uid) filter = Net::LDAP::Filter.eq('memberuid', uid) begin user = find_user(uid)[0][:dn][0] filter |= Net::LDAP::Filter.eq('member', user) rescue UIDNotFoundException # do nothing end @ldap.search( :filter => filter, :base => @group_base, :attributes => ['cn'] ).map { |entry| entry[:cn][0] } end |
#get_logins(userlist) ⇒ Object
20 21 22 23 24 |
# File 'lib/ldap_fluff/netiq_member_service.rb', line 20 def get_logins(userlist) userlist.map do |current_user| find_by_dn(current_user&.downcase)[0][@attr_login][0] end end |