Class: UCB::LDAP::Person
- Includes:
- AffiliationMethods, GenericAttributes
- Defined in:
- lib/ucb_ldap_person.rb
Overview
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
p.addresses #=> Array of Address
p.job_appointments #=> Array of JobAppointment
p.namespaces #=> Array of Namespace
p.student_terms #=> Array of StudentTerm
Attributes
See Ldap::Entry for general information on accessing attribute values.
Defined Under Namespace
Classes: RecordNotFound
Class Method Summary collapse
-
.find_by_uid(uid) ⇒ Object
(also: person_by_uid)
Returns an instance of Person for given uid.
-
.find_by_uids(uids) ⇒ Object
(also: persons_by_uids)
Returns an
Array
of Person for given uids. -
.include_test_entries=(include_test_entries) ⇒ Object
Setter for include_test_entries?.
-
.include_test_entries? ⇒ Boolean
If
true
test entries are included in search results (defalut isfalse
). -
.search(args) ⇒ Object
Exclude test entries from search results unless told otherwise.
Instance Method Summary collapse
- #dept_name ⇒ Object
- #deptid ⇒ Object (also: #dept_code)
-
#job_appointments ⇒ Object
Returns
Array
of JobAppointment for this Person. -
#org_node ⇒ Object
Returns instance of UCB::LDAP::Org corresponding to primary department.
-
#student_terms ⇒ Object
Returns
Array
of StudentTerm for this Person.
Methods included from GenericAttributes
#addresses, #affiliate_affiliations, #email, #firstname, #lastname, #namespaces, #phone, #services, #test?, #uid
Methods included from AffiliationMethods
#affiliate?, #affiliate_academic_case_tracking?, #affiliate_advcon_alumnus?, #affiliate_advcon_attendee?, #affiliate_advcon_caa_member?, #affiliate_advcon_friend?, #affiliate_advcon_i_house_resident?, #affiliate_advcon_student?, #affiliate_advcon_trustee?, #affiliate_aws_only?, #affiliate_billing_only?, #affiliate_committee_member?, #affiliate_concurrent_enrollment?, #affiliate_consultant?, #affiliate_contractor?, #affiliate_departmental?, #affiliate_directory_only?, #affiliate_emeritus?, #affiliate_expiration_date, #affiliate_expired?, #affiliate_hhmi_researcher?, #affiliate_lbl_doe_postdoc?, #affiliate_lbl_op_staff?, #affiliate_maintenance?, #affiliate_staff_affiliate?, #affiliate_staff_retiree?, #affiliate_temp_agency?, #affiliate_test?, #affiliate_visiting?, #affiliate_volunteer?, #affiliations, #employee?, #employee_academic?, #employee_expiration_date, #employee_expired?, #employee_staff?, #has_affiliation?, #has_affiliation_of_type?, #student?, #student_expiration_date, #student_expired?, #student_not_registered?, #student_registered?
Methods inherited from Entry
#assigned_attributes, #attributes, canonical, #canonical, combine_filters, create, create!, #delete, #delete!, #dn, entity_name, find_by_dn, #initialize, make_search_filter, #method_missing, #modify, #modify_operations, net_ldap, #net_ldap, object_classes, schema_attribute, schema_attributes_array, schema_attributes_hash, set_schema_attributes, #setter_method?, tree_base, tree_base=, unique_object_class, #update_attributes, #update_attributes!, #value_getter, #value_setter
Constructor Details
This class inherits a constructor from UCB::LDAP::Entry
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class UCB::LDAP::Entry
Class Method Details
.find_by_uid(uid) ⇒ Object Also known as: person_by_uid
Returns an instance of Person for given uid.
71 72 73 74 |
# File 'lib/ucb_ldap_person.rb', line 71 def find_by_uid(uid) uid = uid.to_s find_by_uids([uid]).first end |
.find_by_uids(uids) ⇒ Object Also known as: persons_by_uids
Returns an Array
of Person for given uids.
78 79 80 81 82 |
# File 'lib/ucb_ldap_person.rb', line 78 def 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) ⇒ Object
Setter for include_test_entries?
98 99 100 |
# File 'lib/ucb_ldap_person.rb', line 98 def include_test_entries=(include_test_entries) @include_test_entries = include_test_entries end |
.include_test_entries? ⇒ Boolean
If true
test entries are included in search results (defalut is false
).
93 94 95 |
# File 'lib/ucb_ldap_person.rb', line 93 def include_test_entries? @include_test_entries ? true : false end |
.search(args) ⇒ Object
Exclude test entries from search results unless told otherwise.
86 87 88 89 |
# File 'lib/ucb_ldap_person.rb', line 86 def search(args) #:nodoc: results = super include_test_entries? ? results : results.reject{|person| person.test?} end |
Instance Method Details
#dept_name ⇒ Object
110 111 112 |
# File 'lib/ucb_ldap_person.rb', line 110 def dept_name berkeleyEduUnitCalNetDeptName end |
#deptid ⇒ Object Also known as: dept_code
105 106 107 |
# File 'lib/ucb_ldap_person.rb', line 105 def deptid berkeleyEduPrimaryDeptUnit end |
#job_appointments ⇒ Object
Returns Array
of JobAppointment for this Person. Requires a bind with access to job appointments. See UCB::LDAP.authenticate().
117 118 119 |
# File 'lib/ucb_ldap_person.rb', line 117 def job_appointments @job_appointments ||= JobAppointment.find_by_uid(uid) end |
#org_node ⇒ Object
Returns instance of UCB::LDAP::Org corresponding to primary department.
130 131 132 |
# File 'lib/ucb_ldap_person.rb', line 130 def org_node @org_node ||= UCB::LDAP::Org.find_by_ou(deptid) end |
#student_terms ⇒ Object
Returns Array
of StudentTerm for this Person. Requires a bind with access to student terms. See UCB::LDAP.authenticate().
124 125 126 |
# File 'lib/ucb_ldap_person.rb', line 124 def student_terms @student_terms ||= StudentTerm.find_by_uid(uid) end |