Class: Socialcast::CommandLine::LDAPConnector
- Inherits:
-
Object
- Object
- Socialcast::CommandLine::LDAPConnector
show all
- Defined in:
- lib/socialcast/command_line/ldap_connector.rb
Defined Under Namespace
Classes: ConcurrentSearchError
Constant Summary
collapse
- UNIQUE_IDENTIFIER_ATTRIBUTE =
"unique_identifier"
- EMAIL_ATTRIBUTE =
"email"
- MANAGER_ATTRIBUTE =
"manager"
- PRIMARY_ATTRIBUTES =
[UNIQUE_IDENTIFIER_ATTRIBUTE, 'first_name', 'last_name', 'employee_number']
- CONTACT_ATTRIBUTES =
[EMAIL_ATTRIBUTE, 'location', 'cell_phone', 'office_phone']
- PROFILE_PHOTO_ATTRIBUTE =
'profile_photo'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(connection_name, config) ⇒ LDAPConnector
23
24
25
26
|
# File 'lib/socialcast/command_line/ldap_connector.rb', line 23
def initialize(connection_name, config)
@connection_name = connection_name
@config = config
end
|
Instance Attribute Details
#attribute_mappings ⇒ Object
Returns the value of attribute attribute_mappings.
17
18
19
|
# File 'lib/socialcast/command_line/ldap_connector.rb', line 17
def attribute_mappings
@attribute_mappings
end
|
#connection_name ⇒ Object
Returns the value of attribute connection_name.
17
18
19
|
# File 'lib/socialcast/command_line/ldap_connector.rb', line 17
def connection_name
@connection_name
end
|
Class Method Details
.attribute_mappings_for(connection_name, config) ⇒ Object
19
20
21
|
# File 'lib/socialcast/command_line/ldap_connector.rb', line 19
def self.attribute_mappings_for(connection_name, config)
config['connections'][connection_name]['mappings'] || config.fetch('mappings', {})
end
|
Instance Method Details
#each_photo_hash ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'lib/socialcast/command_line/ldap_connector.rb', line 39
def each_photo_hash
ldap.open do
each_ldap_entry(ldap_photo_search_attributes) do |entry|
photo_hash = build_photo_hash_from_mappings(entry)
yield photo_hash if photo_hash.present?
end
end
end
|
#each_user_hash ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/socialcast/command_line/ldap_connector.rb', line 28
def each_user_hash
ldap.open do
fetch_group_unique_identifiers
fetch_dn_to_email_hash
each_ldap_entry(ldap_user_search_attributes) do |entry|
yield build_user_hash_from_mappings(entry)
end
end
end
|
#fetch_user_hash(identifier, options) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/socialcast/command_line/ldap_connector.rb', line 48
def fetch_user_hash(identifier, options)
ldap.open do
fetch_group_unique_identifiers
fetch_dn_to_email_hash
options = options.dup
identifying_field = options.delete(:identifying_field) || UNIQUE_IDENTIFIER_ATTRIBUTE
filter = if connection_config['filter'].present?
Net::LDAP::Filter.construct(connection_config['filter'])
else
Net::LDAP::Filter.pres("objectclass")
end
filter = filter & Net::LDAP::Filter.construct("#{attribute_mappings[identifying_field]}=#{identifier}")
search(:base => connection_config['basedn'], :filter => filter, :attributes => ldap_user_search_attributes, :size => 1) do |entry|
return build_user_hash_from_mappings(entry)
end
nil
end
end
|