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