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



15
16
17
18
19
20
# File 'lib/ldap_groups_lookup/behavior.rb', line 15

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

#ldap_mailObject

Returns String object’s mail attribute.

Returns:

  • String object’s mail attribute



8
9
10
11
# File 'lib/ldap_groups_lookup/behavior.rb', line 8

def ldap_mail
  return '' unless respond_to?(:ldap_lookup_key) && ldap_lookup_key.to_s.size.positive?
  LDAPGroupsLookup.lookup_mail(ldap_lookup_key)
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)


25
26
27
28
29
30
31
# File 'lib/ldap_groups_lookup/behavior.rb', line 25

def member_of_ldap_group?(groups)
  return false unless respond_to?(:ldap_lookup_key) && ldap_lookup_key.to_s.size.positive?
  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