Class: UCB::LDAP::Affiliation

Inherits:
Entry
  • Object
show all
Defined in:
lib/ucb_ldap_affiliation.rb

Overview

UCB::LDAP::Affiliation

This class models a persons affiliate entries in the UCB LDAP directory.

affiliations = Affiliation.find_by_uid("1234")  #=> [#<UCB::LDAP::Affiliation: ...>, ...]

Affiliation are usually loaded through a Person instance:

p = Person.find_by_uid("1234")    #=> #<UCB::LDAP::Person: ...>
affs = p.affiliations        #=> [#<UCB::LDAP::Affiliation: ...>, ...]

Note on Binds

You must have a privileged bind and pass your credentials to UCB::LDAP.authenticate() before performing your Affiliation search.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entry

#attributes, #canonical, canonical, combine_filters, create, create!, #delete, #delete!, #dn, entity_name, find_by_dn, hydrate, #initialize, make_search_filter, #method_missing, #modify, #modify_operations, #net_ldap, net_ldap, #new_record?, object_classes, required_attributes, schema_attribute, schema_attributes_array, schema_attributes_hash, search, set_schema_attributes, #setter_method?, #tainted_attributes, 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

Returns an Array of Affiliation for uid. Returns an empty Array ([]) if nothing is found.



75
76
77
78
79
# File 'lib/ucb_ldap_affiliation.rb', line 75

def find_by_uid(uid)
  base = "uid=#{uid},ou=people,dc=berkeley,dc=edu"
  filter = Net::LDAP::Filter.eq("objectclass", 'berkeleyEduPersonAffiliate')
  search(:base => base, :filter => filter)
end

Instance Method Details

#affiliate_idObject



35
36
37
# File 'lib/ucb_ldap_affiliation.rb', line 35

def affiliate_id
  berkeleyEduAffID.first
end

#affiliate_typeObject



39
40
41
# File 'lib/ucb_ldap_affiliation.rb', line 39

def affiliate_type
  berkeleyEduAffType
end

#create_datetimeObject



23
24
25
# File 'lib/ucb_ldap_affiliation.rb', line 23

def create_datetime
  berkeleyEduAffCreateDate
end

#dept_codeObject



63
64
65
# File 'lib/ucb_ldap_affiliation.rb', line 63

def dept_code
  departmentNumber.first
end

#dept_nameObject



67
68
69
# File 'lib/ucb_ldap_affiliation.rb', line 67

def dept_name
  berkeleyEduUnitCalNetDeptName
end

#expiration_dateObject



31
32
33
# File 'lib/ucb_ldap_affiliation.rb', line 31

def expiration_date
   UCB::LDAP.local_date_parse(berkeleyEduAffExpDate)
end

#expired_byObject



27
28
29
# File 'lib/ucb_ldap_affiliation.rb', line 27

def expired_by
  berkeleyEduAffExpBy
end

#first_nameObject



43
44
45
# File 'lib/ucb_ldap_affiliation.rb', line 43

def first_name
  givenName.first
end

#last_nameObject



51
52
53
# File 'lib/ucb_ldap_affiliation.rb', line 51

def last_name
  sn.first
end

#middle_nameObject



47
48
49
# File 'lib/ucb_ldap_affiliation.rb', line 47

def middle_name
  berkeleyEduMiddleName
end

#modified_byObject



55
56
57
# File 'lib/ucb_ldap_affiliation.rb', line 55

def modified_by
  berkeleyEduModifiedBy
end

#sourceObject



59
60
61
# File 'lib/ucb_ldap_affiliation.rb', line 59

def source
  berkeleyEduPersonAffiliateSource
end