Class: Ddr::Auth::LdapGateway

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/ddr/auth/ldap_gateway.rb

Constant Summary collapse

SCOPE =
Net::LDAP::SearchScope_SingleLevel

Instance Method Summary collapse

Constructor Details

#initializeLdapGateway

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)

Parameters:

  • eppn (String)

    the eduPersonPrincipalName value

Returns:

  • (Array)

    the list of affiliations for the principal



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.message
    []
  end
end