There are some known limitation and inconsistency with user photos synchronization from Active Directory (using the thumbnailPhoto attribute) to Azure AD and Office 365 apps: Exchange, SharePoint and Skype for Business (aka Lync), specifically if you want to upload high resolution photos of your users that will span across all of Office 365 services.
After spending some research time around this issue, here are my findings:
- “High Resolution” in our context is a 648 x 648 pixel dimension size JPEG photo
- The Active Directory thumbnailPhoto attribute value is limited to about 100KB in size – this will mostly prevent you from uploading a “high resolution” photo
- “Common knowledge” around synchronizing the thumbnailPhoto using Directory Synchronization (aka DirSync / AAD Sync/ AAD Connect) to Office 365 / Azure AD is that the attribute should not exceed 10KB, and the recommended photo dimension is 96 x 96 pixels – This is really an “Exchange” limit as far as I know..
- When User Photos are stored within Office 365 a web service handles requests for the photo with predefined allowed sizes for example – https://outlook.office365.com/owa/service.svc/s/GetPersonaPhoto?email=emailaddress@domain.com&size=HR648x648
- Modify this to your email address to try this out
- There are quite a few possible sizes, try for example 96×96 and 240×240 to get the idea
- SharePoint holds a separate location and also a few versions for it’s images within each users profile folder and is suppose to synchronize those from Exchange Web Services
- See this post for additional details around SharePoint – Options for SharePoint User Profile Properties and Photos
- The Set-UserPhoto cmdlet from Exchange (Online and On-Prem) allows you to save high resolution photos, and integrates with Skype for Business Server 2015 (also for Lync 2013) and SharePoint 2013/2016 – each product with it’s own flow which I’m not going into explaining.
- See Configure the use of high-resolution photos in Skype for Business Server 2015
- SharePoint part is covered at Options for SharePoint User Profile Properties and Photos
So to summarize at this point, we want to import high resolution photos to our users. If we rely on the thumbnailPhoto attribute value from Active Directory, we will end up with low resolution images (needs more JPEG effect) or inconsistent results if we look on the SharePoint case.
To upload high resolution photos to Office 365, you should use Set-UserPhoto. This approach works great for Exchange Online, Skype for Business and Azure AD. Although promising, my testing (and others..) showed that if your users’ photos were previously synced to SharePoint Online – they will not necessarily be updated using this method.
Here is my take on solving this, in a somewhat chronological order:
- If you need your on-premises thumbnailPhoto attribute populated, keep your current practice of maintaining them.
- To avoid future inconsistencies – use “Azure AD app and attribute filtering” to filter out thumbnailPhoto using Azure AD Connect – Custom installation of Azure AD Connect
- Utilize the Set-UserPhoto cmdlet in Exchange Online PowerShell to upload your users high resolutions (648×648 px) photos
- Note Uploading High Resolution Photos using PowerShell for Office 365 to workaround – “The remote server returned an error: (413) Request Entity Too Large” error if you get this.
- To upload your users high resolution photos to SharePoint online use the Core.ProfilePictureUploader sample app from the OfficeDev PnP GitHub repo.
- To make this easier to non coders 🙂 I’ve complied the code sample for your usage – http://ilantz.com/files/Core.ProfilePictureUploader.zip
- Get the source code here and also make sure to read the FAQ – https://github.com/OfficeDev/PnP/tree/master/Samples/Core.ProfilePictureUploader
- Follow the explanations in the GitHub page link above around how to run the utility (configuration.xml , the CSV input file and the command syntax).
- Make sure your pictures are JPEG files…
- This sample app is also documented here, with some additional explanations – Upload user profile pictures sample app for SharePoint
- To make this easier to non coders 🙂 I’ve complied the code sample for your usage – http://ilantz.com/files/Core.ProfilePictureUploader.zip
That’s it !
Hope this helps anyone, please comment if it did.
ilantz
From what I can tell, if you don’t have an Office 365 Mailbox on the account, the set-userphoto command does not work.
Yeah. That’s correct.
Your pre-compiled EXE seems to be missing something:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.SharePoint.Client.Runtime, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c’ or one of its dependencies. The system cannot find the file specified.
at Contoso.Core.ProfilePictureUploader.Program.InitializeWebService()
at Contoso.Core.ProfilePictureUploader.Program.Main(String[] args)
Thanks for the report! I’ll look into that
Thanks for the writeup. Let’s say I have Azure AD Connect syncing an account with empty thumbnailPhoto and jpegPhoto attributes. If I run the Set-UserPhoto command, will the photo be removed at the next Directory synchronization?
Should be easy to test, but as far as I can think – yes it should be overwritten, unless you will filter out these attributes.