How can I pull the thumbnailphoto from Azure AD?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2018 11:10 AM
need to pull in a profile photo for users from Azure AD to ServiceNow.
How can this be done? Do we need to create a GraphAPI or can I somehow fetch them another way from Azure AD? converting them to base 64
Labels:
- Labels:
-
Integrations
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2018 06:00 AM
You can use get User Info activity that is under Azure AD and parse out "thumbnailphoto" attribute and use below code to convert photo. replace fields next to xxxxx.
var sourcePhoto = workflow.scratchpad.xxxxxxxxx;
var sysDecodedAttachment = new GlideSysAttachment();
var DecodedBytes = GlideStringUtil.base64DecodeAsBytes(sourcePhoto);
var attID = sysDecodedAttachment.write(target, 'photo', '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 = user.sys_idxxxxxxxxxx;
newAttachment.content_type = 'image/jpeg';
newAttachment.update();
}