Forum Discussion
andrewraia
May 24, 2019Copper Contributor
Syncing Profile Pictures with Office 365 and Active Directory
Good Afternoon All, I wanted to share a script I came up with to help keep our active directory profile photos in sync with Office 365 and SharePoint Online, but first a little background on WHY I d...
helenegeldof
Jun 11, 2020Copper Contributor
After contacting Microsoft support I received the following feedback:
the user can log into o365 and browse to the following url to initiate the sync
https://yoursite.sharepoint.com/_layouts/15/userphoto.aspx?size=M&username=user@yourdomain
So I wrote some javascript code and included this on our main home page of our Sharepoint site.
<script type="text/javascript">
var loginName = _spPageContextInfo.userLoginName;
var url = "https://yoursite.sharepoint.com/_layouts/15/userphoto.aspx?size=M&username="+encodeURIComponent(loginName);
//alert(url);
document.writeln ("<img src='" + url + "' width='10'/>")
</script>After this, the user profile pictures started to sync in our Sharepoint environment.
Since I have struggled with this issue many hours, days even, I thought it would be a good idea to share this. I hope someone will benefit from this solution.