Module: LDAPGroupsLookup::Behavior

Defined in:
lib/ldap_groups_lookup/behavior.rb

Instance Method Summary collapse

Instance Method Details

#ldap_groupsArray

Searches object’s nested LDAP groups by value of ldap_lookup_key

Returns:

  • (Array)

    all of the object’s LDAP groups, sorted



9
10
11
12
13
14
# File 'lib/ldap_groups_lookup/behavior.rb', line 9

def ldap_groups
  return [] unless respond_to? :ldap_lookup_key
  LDAPGroupsLookup.walk_ldap_groups(
      LDAPGroupsLookup.ldap_member_of(ldap_lookup_key)
  ).sort
end

#member_of_ldap_group?(groups) ⇒ Boolean

Checks if a user is in a group’s membership tree

Parameters:

  • groups (Array)

    is a list of group CN strings to search within

Returns:

  • (Boolean)


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

def member_of_ldap_group?(groups)
  return false unless respond_to? :ldap_lookup_key
  return false if LDAPGroupsLookup.service.nil?
  groups = [groups] if groups.is_a? String
  dn = LDAPGroupsLookup.lookup_dn ldap_lookup_key
  return LDAPGroupsLookup.walk_ldap_members(groups, dn)
end