class LdapFluff::FreeIPA::MemberService

handles the naughty bits of posix ldap

Attributes

ldap[RW]

Public Class Methods

new(ldap,group_base) click to toggle source
# File lib/ldap_fluff/freeipa_member_service.rb, line 8
def initialize(ldap,group_base)
  @ldap = ldap
  @group_base = group_base
end

Public Instance Methods

_group_names_from_cn(grouplist) click to toggle source
# File lib/ldap_fluff/freeipa_member_service.rb, line 28
def _group_names_from_cn(grouplist)
  p = Proc.new { |g| g.sub(%r.*?cn=(.*?),.*/, '\1') }
  grouplist.collect(&p)
end
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 15
def find_user_groups(uid)
  user = @ldap.search(:filter => name_filter(uid))
  raise UIDNotFoundException if (user == nil || user.empty?)
  # if group data is missing, they aren't querying with a user
  # with enough privileges
  raise InsufficientQueryPrivilegesException if user.size <= 1
  _group_names_from_cn(user[1][:memberof])
end
name_filter(uid) click to toggle source
# File lib/ldap_fluff/freeipa_member_service.rb, line 24
def name_filter(uid)
  Net::LDAP::Filter.eq("uid",uid)
end