Module: AnuLdap
- Defined in:
- lib/anu-ldap.rb
Overview
This module encapsulates queries of the ANU LDAP server.
Class Method Summary collapse
-
.authenticate(uni_id, password) ⇒ Object
Authenticate credentials against ANU LDAP.
-
.find_all_by_email(email) ⇒ Object
Find all ANU LDAP entries with the given email.
-
.find_all_by_uni_id(uni_id) ⇒ Object
Find all ANU LDAP entries with the given uni_id.
-
.find_by_email(email) ⇒ Object
Find first ANU LDAP entry with the given email.
-
.find_by_uni_id(uni_id) ⇒ Object
Find first ANU LDAP entry with the given uni_id.
Class Method Details
.authenticate(uni_id, password) ⇒ Object
Authenticate credentials against ANU LDAP.
Returns true if authentication is successful, and false otherwise.
41 42 43 44 45 46 |
# File 'lib/anu-ldap.rb', line 41 def self.authenticate(uni_id, password) ldap = get_new_ldap() ldap.auth "uid=#{uni_id}, ou=people, o=anu.edu.au", password ldap.bind end |
.find_all_by_email(email) ⇒ Object
Find all ANU LDAP entries with the given email.
Return entries as a hash with keys :uni_id, :email, :given_name, :surname, :full_name.
26 27 28 |
# File 'lib/anu-ldap.rb', line 26 def self.find_all_by_email(email) find_by("mail", email) end |
.find_all_by_uni_id(uni_id) ⇒ Object
Find all ANU LDAP entries with the given uni_id.
Return entries as a hash with keys :uni_id, :email, :given_name, :surname, :full_name.
10 11 12 |
# File 'lib/anu-ldap.rb', line 10 def self.find_all_by_uni_id(uni_id) find_by("uid", uni_id) end |
.find_by_email(email) ⇒ Object
Find first ANU LDAP entry with the given email.
Return the entry as a hash with keys :uni_id, :email, :given_name, :surname, :full_name.
34 35 36 |
# File 'lib/anu-ldap.rb', line 34 def self.find_by_email(email) find_all_by_email(email).first end |
.find_by_uni_id(uni_id) ⇒ Object
Find first ANU LDAP entry with the given uni_id.
Return the entry as a hash with keys :uni_id, :email, :given_name, :surname, :full_name.
18 19 20 |
# File 'lib/anu-ldap.rb', line 18 def self.find_by_uni_id(uni_id) find_all_by_uni_id(uni_id).first end |