AD Thumbnail Photos not importing using LDAP Import

Elizabeth Hemon
Tera Contributor

I am using this article to attempt to import thumbnails from Active Directory (LDAP): https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0597756

 

However when the script runs, it is skipping this section below. I used logging to identify that the script is identifying that the thumbnail doesn't exist, and also checked that the thumbnail exists in the import set table. Our thumbnails are pretty small, but I still increased the table column to the recommended 13,500. I've tried to add the mid server properties directly to the properties file on the mid server and have restarted the mid several times.

 

    if (newAttachment.next()) {
        newAttachment.table_name = "ZZ_YYsys_user";
        newAttachment.table_sys_id = target.sys_id;
        newAttachment.content_type = 'image/jpeg';
        newAttachment.update();
    }

 

Has anyone used this article successfully in Tokyo?

2 REPLIES 2

Community Alums
Not applicable

Elizabeth Hemon
Tera Contributor

I was able to fix the issue by replacing the function and adding set user photo:

 

function attachPhoto(){

var DecodedBytes = GlideStringUtil.base64DecodeAsBytes(source.u_thumbnailphoto);
var attID = new GlideSysAttachment().write(target, 'photo.jpeg', 'image/jpeg', DecodedBytes);

var newAttachment = new GlideRecord("sys_attachment");
newAttachment.addQuery("sys_id", attID);
newAttachment.query();
if (newAttachment.next()) {
newAttachment.table_name = "ZZ_YYsys_user";
newAttachment.table_sys_id = target.sys_id;
newAttachment.content_type = 'image/jpeg';
newAttachment.update();
}

// Set photo for user
target.photo = attID;
target.update();

 

Found in the responses from @warren_chan here:

https://www.servicenow.com/community/developer-forum/import-user-photo-from-ldap-into-s-n-reloaded/m...