Class: LdapFluff::FreeIPA::MemberService
- Inherits:
-
GenericMemberService
- Object
- GenericMemberService
- LdapFluff::FreeIPA::MemberService
- Defined in:
- lib/ldap_fluff/freeipa_member_service.rb
Direct Known Subclasses
Defined Under Namespace
Classes: GIDNotFoundException, InsufficientQueryPrivilegesException, UIDNotFoundException
Instance Attribute Summary
Attributes inherited from GenericMemberService
Instance Method Summary collapse
-
#find_user_groups(uid) ⇒ Object
return an ldap user with groups attached note : this method is not particularly fast for large ldap systems.
-
#get_groups(grouplist) ⇒ Object
extract the group names from the LDAP style response, return string will be something like CN=bros,OU=bropeeps,DC=jomara,DC=redhat,DC=com.
-
#initialize(ldap, config) ⇒ MemberService
constructor
A new instance of MemberService.
Methods inherited from GenericMemberService
#find_by_dn, #find_group, #find_user, #get_login_from_entry, #get_logins, #get_netgroup_users, #group_filter, #name_filter
Constructor Details
#initialize(ldap, config) ⇒ MemberService
4 5 6 7 |
# File 'lib/ldap_fluff/freeipa_member_service.rb', line 4 def initialize(ldap, config) @attr_login = (config.attr_login || 'uid') super end |
Instance Method Details
#find_user_groups(uid) ⇒ Object
return an ldap user with groups attached note : this method is not particularly fast for large ldap systems
11 12 13 14 15 16 17 18 |
# File 'lib/ldap_fluff/freeipa_member_service.rb', line 11 def find_user_groups(uid) user = find_user(uid) # if group data is missing, they aren't querying with a user # with enough privileges user.delete_if { |u| u.nil? || !u.respond_to?(:attribute_names) || !u.attribute_names.include?(:memberof) } raise InsufficientQueryPrivilegesException if user.size < 1 get_groups(user[0][:memberof]) end |
#get_groups(grouplist) ⇒ Object
extract the group names from the LDAP style response, return string will be something like CN=bros,OU=bropeeps,DC=jomara,DC=redhat,DC=com
23 24 25 26 27 28 29 30 31 |
# File 'lib/ldap_fluff/freeipa_member_service.rb', line 23 def get_groups(grouplist) grouplist.map(&:downcase).collect do |g| if /.*?ipauniqueid=(.*?)/.match?(g) @ldap.search(:base => g)[0][:cn][0] else g.sub(/.*?cn=(.*?),.*/, '\1') end end.compact end |