class LdapFluff::FreeIPA::MemberService
Public Class Methods
new(ldap, config)
click to toggle source
Calls superclass method
LdapFluff::GenericMemberService::new
# File lib/ldap_fluff/freeipa_member_service.rb, line 4 def initialize(ldap, config) @attr_login = (config.attr_login || 'uid') super end
Public Instance Methods
find_user_groups(uid)
click to toggle source
return an ldap user with groups attached note : this method is not particularly fast for large ldap systems
# 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)
click to toggle source
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
# 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