Class: LdapFluff::Posix::MemberService

Inherits:
GenericMemberService show all
Defined in:
lib/ldap_fluff/posix_member_service.rb

Overview

handles the naughty bits of posix ldap

Direct Known Subclasses

NetIQ::MemberService, NetgroupMemberService

Defined Under Namespace

Classes: GIDNotFoundException, UIDNotFoundException

Instance Attribute Summary

Attributes inherited from GenericMemberService

#ldap

Instance Method Summary collapse

Methods inherited from GenericMemberService

#find_by_dn, #find_group, #get_groups, #get_login_from_entry, #get_logins, #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/posix_member_service.rb', line 5

def initialize(ldap, config)
   = (config. || 'memberuid')
  @use_rfc4519_group_membership = config.use_rfc4519_group_membership
  super
end

Instance Method Details

#find_user(uid, base_dn = @base) ⇒ Object



11
12
13
14
15
# File 'lib/ldap_fluff/posix_member_service.rb', line 11

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

#find_user_groups(uid) ⇒ Object

return an ldap user with groups attached note : this method is not particularly fast for large ldap systems



19
20
21
22
23
24
25
# File 'lib/ldap_fluff/posix_member_service.rb', line 19

def find_user_groups(uid)
  user = find_user(uid).first
  @ldap.search(
    :filter => user_group_filter(uid, user[:dn].first),
    :base => @group_base, :attributes => ["cn"]
  ).map { |entry| entry[:cn][0] }
end