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.

Constant Summary

Constants inherited from Entry

Entry::TESTING

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Entry

#assigned_attributes, #attributes, canonical, #canonical, combine_filters, create, create!, #dn, entity_name, filter_in, find_by_dn, #initialize, make_search_filter, #method_missing, net_ldap, #net_ldap, object_classes, required_attributes, required_schema_attributes, schema_attribute, schema_attributes_array, schema_attributes_hash, search, set_schema_attributes, tree_base, tree_base=, unique_object_class

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.



77
78
79
80
81
# File 'lib/ucb_ldap/affiliation.rb', line 77

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



37
38
39
# File 'lib/ucb_ldap/affiliation.rb', line 37

def affiliate_id
  berkeleyEduAffID.first
end

#affiliate_typeObject



41
42
43
# File 'lib/ucb_ldap/affiliation.rb', line 41

def affiliate_type
  berkeleyEduAffType
end

#create_datetimeObject



23
24
25
26
# File 'lib/ucb_ldap/affiliation.rb', line 23

def create_datetime
  warn "DEPRECATED: create_datetime is no longer supported"
  []
end

#dept_codeObject



65
66
67
# File 'lib/ucb_ldap/affiliation.rb', line 65

def dept_code
  departmentNumber.first
end

#dept_nameObject



69
70
71
# File 'lib/ucb_ldap/affiliation.rb', line 69

def dept_name
  warn "DEPRECATED: dept_name is no longer supported"
end

#expiration_dateObject



32
33
34
35
# File 'lib/ucb_ldap/affiliation.rb', line 32

def expiration_date
  warn "DEPRECATED: expiration_date is no longer supported"
  []
end

#expired_byObject



28
29
30
# File 'lib/ucb_ldap/affiliation.rb', line 28

def expired_by
  berkeleyEduAffExpBy
end

#first_nameObject



45
46
47
# File 'lib/ucb_ldap/affiliation.rb', line 45

def first_name
  givenName.first
end

#last_nameObject



53
54
55
# File 'lib/ucb_ldap/affiliation.rb', line 53

def last_name
  sn.first
end

#middle_nameObject



49
50
51
# File 'lib/ucb_ldap/affiliation.rb', line 49

def middle_name
  berkeleyEduMiddleName
end

#modified_byObject



57
58
59
# File 'lib/ucb_ldap/affiliation.rb', line 57

def modified_by
  berkeleyEduModifiedBy
end

#sourceObject



61
62
63
# File 'lib/ucb_ldap/affiliation.rb', line 61

def source
  berkeleyEduPersonAffiliateSource
end