Class: Ddr::Auth::LdapGateway
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Ddr::Auth::LdapGateway
- Defined in:
- lib/ddr/auth/ldap_gateway.rb
Constant Summary collapse
- SCOPE =
Net::LDAP::SearchScope_SingleLevel
Instance Method Summary collapse
-
#affiliations(eppn) ⇒ Array
Returns a list of affiliations for a principal (person).
-
#initialize ⇒ LdapGateway
constructor
A new instance of LdapGateway.
Constructor Details
#initialize ⇒ LdapGateway
Returns a new instance of LdapGateway.
10 11 12 |
# File 'lib/ddr/auth/ldap_gateway.rb', line 10 def initialize super Net::LDAP.new(config) end |
Instance Method Details
#affiliations(eppn) ⇒ Array
Returns a list of affiliations for a principal (person)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ddr/auth/ldap_gateway.rb', line 17 def affiliations(eppn) filter = Net::LDAP::Filter.eq("eduPersonPrincipalName", eppn) result_set = search(scope: SCOPE, filter: filter, size: 1, attributes: ["eduPersonAffiliation"]) if result_set result = result_set.first result ? result[:edupersonaffiliation] : [] else # error Rails.logger.error get_operation_result. [] end end |