Module: OmniAuth::Pubcookie::CMULdap

Included in:
Strategies::CMU
Defined in:
lib/omniauth/pubcookie/cmu_ldap.rb

Instance Method Summary collapse

Instance Method Details

#lookup_andrew_id(username) ⇒ Object

Thanks to Marshall Roch for the original jump start for this code.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/omniauth/pubcookie/cmu_ldap.rb', line 8

def lookup_andrew_id username
  ldap = Net::LDAP.new :host => 'ldap.andrew.cmu.edu', :port => 389

  filter = Net::LDAP::Filter.eq('cmuAndrewID', username)
  ldap.search(:base => 'ou=Person,dc=cmu,dc=edu',
              :filter => filter, :return_result => true) do |entry|
    results = {}

    entry.each do |attribute, values|
      results[attribute] = values.first
    end

    return results
  end

  nil
end