Module: LDAPGroupsLookup::Behavior
- Defined in:
- lib/ldap_groups_lookup/behavior.rb
Instance Method Summary collapse
-
#ldap_groups ⇒ Array
Searches object’s nested LDAP groups by value of ldap_lookup_key.
-
#ldap_mail ⇒ Object
String object’s mail attribute.
-
#member_of_ldap_group?(groups) ⇒ Boolean
Checks if a user is in a group’s membership tree.
Instance Method Details
#ldap_groups ⇒ Array
Searches object’s nested LDAP groups by value of ldap_lookup_key
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_mail ⇒ Object
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
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 |