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

find_by_uid(uid) click to toggle source

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
find_by_uids(uids) click to toggle source

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
include_test_entries=(include_test_entries) click to toggle source

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
include_test_entries?() click to toggle source

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
person_by_uid(uid) click to toggle source
# File lib/ucb_ldap/person.rb, line 75
def self.person_by_uid(uid)
  find_by_uid(uid)
end
persons_by_uids(uids) click to toggle source
# File lib/ucb_ldap/person.rb, line 88
def self.persons_by_uids(uids)
  find_by_uids(uids)
end

Public Instance Methods

departments() click to toggle source
# File lib/ucb_ldap/person.rb, line 127
def departments
  departmentNumber
end
dept_code()
Alias for: deptid
dept_name() click to toggle source
# 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
deptid() click to toggle source
# File lib/ucb_ldap/person.rb, line 116
def deptid
  berkeleyEduPrimaryDeptUnit
end
Also aliased as: dept_code
expired?() click to toggle source

Returns expired status

False by definition for normal users, overridable by subclasses

# File lib/ucb_ldap/person.rb, line 163
def expired?
  false
end
job_appointments() click to toggle source

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
org_node() click to toggle source

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
student_terms() click to toggle source

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