17 lines
413 B
Ruby
17 lines
413 B
Ruby
module LdapManager
|
|
class FetchAvatar < LdapManagerService
|
|
def initialize(cn:)
|
|
@cn = cn
|
|
end
|
|
|
|
def call
|
|
treebase = ldap_config["base"]
|
|
attributes = %w{ jpegPhoto }
|
|
filter = Net::LDAP::Filter.eq("cn", @cn)
|
|
|
|
entry = client.search(base: treebase, filter: filter, attributes: attributes).first
|
|
entry.try(:jpegPhoto) ? entry.jpegPhoto.first : nil
|
|
end
|
|
end
|
|
end
|