class UCB::LDAP::Person
UCB::LDAP::Person
¶ ↑
Class for accessing the People tree of the UCB
LDAP
directory.
You can search by specifying your own filter:
e = Person.search(:filter => {:uid => 123})
Or you can use a convenience search method:
e = Person.find_by_uid("123")
Access attributes as if they were instance methods:
e = Person.find_by_uid("123") e.givenname #=> "John" e.sn #=> "Doe"
Methods with friendly names are provided for accessing attribute values:
e = Person.person_by_uid("123") e.firstname #=> "John" e.lastname #=> "Doe"
There are other convenience methods:
e = Person.person_by_uid("123") e.affiliations #=> ["EMPLOYEE-TYPE-STAFF"] e.employee? #=> true e.employee_staff? #=> true e.employee_academic? #=> false e.student? #=> false
Other Parts of the Tree¶ ↑
You can access other parts of the LDAP
directory through Person
instances:
p = Person.find_by_uid("123") p.org_node #=> Org p.affiliations #=> Array of Affiliation
Attributes¶ ↑
See Ldap::Entry for general information on accessing attribute values.
Public Class Methods
Returns an instance of Person
for given uid.
# File lib/ucb_ldap/person.rb, line 70 def self.find_by_uid(uid) uid = uid.to_s find_by_uids([uid]).first end
Returns an Array
of Person
for given uids.
# File lib/ucb_ldap/person.rb, line 82 def self.find_by_uids(uids) return [] if uids.size == 0 filters = uids.map { |uid| Net::LDAP::Filter.eq("uid", uid) } search(:filter => self.combine_filters(filters, '|')) end
Setter for include_test_entries?
# File lib/ucb_ldap/person.rb, line 111 def self.include_test_entries=(include_test_entries) @include_test_entries = include_test_entries end
If true
test entries are included in search results (defalut is false
).
# File lib/ucb_ldap/person.rb, line 104 def self.include_test_entries? @include_test_entries ? true : false end
# File lib/ucb_ldap/person.rb, line 75 def self.person_by_uid(uid) find_by_uid(uid) end
# File lib/ucb_ldap/person.rb, line 88 def self.persons_by_uids(uids) find_by_uids(uids) end
Public Instance Methods
# File lib/ucb_ldap/person.rb, line 127 def departments departmentNumber end
# File lib/ucb_ldap/person.rb, line 122 def dept_name warn "DEPRECATED: LDAP no longer returns department names for person records. You'll need to look up the department code in the org tree. The ucb_orgs gem can help with this" deptid end
# File lib/ucb_ldap/person.rb, line 116 def deptid berkeleyEduPrimaryDeptUnit end
Returns expired status
False by definition for normal users, overridable by subclasses
# File lib/ucb_ldap/person.rb, line 163 def expired? false end
Returns Array
of JobAppointment
for this Person
. Requires a bind with access to job appointments. See UCB::LDAP.authenticate()
.
# File lib/ucb_ldap/person.rb, line 136 def job_appointments warn "DEPRECATED: LDAP no longer contains job appointment data - you now need to go through HCM. This method will always return an empty Array" [] end
Returns instance of UCB::LDAP::Org
corresponding to primary department.
# File lib/ucb_ldap/person.rb, line 154 def org_node @org_node ||= UCB::LDAP::Org.find_by_ou(deptid) end
Returns Array
of StudentTerm
for this Person
. Requires a bind with access to student terms. See UCB::LDAP.authenticate()
.
# File lib/ucb_ldap/person.rb, line 146 def student_terms @student_terms ||= StudentTerm.find_by_uid(uid) end