If you have spread the MySite and a web application into separated SharePoint Web Application and both of these is using AD FS for authentication. You maybe noticed that you are not able to load user profile thumbnails from the MySite. This is because a token is not issued from the MySite web application and Cross-Origin Resource Sharing (CORS) that is a security measure.
But luckily Microsoft have acknowledged this and have added a PowerShell command that allows to load pictures/resources from other SharePoint web applications on the same farm.To enable this, use the following PowerShell snippet, remember to run it in the SharePoint Management Shell.
1 2 3 4 5 6 7 8 |
#Get the SharePoint web application. $wa = Get-SPWebApplication "http://intranet.contoso.com"; #Enable cross resource sharing. $wa.CrossDomainPhotosEnabled = $true; #Update the SharePoint web application. $wa.Update(); |
Basically it uses the userphoto.aspx, to make the request to the other web application. It will change the “src” attribute in the “<img>” tag, from:
1 |
<img src="http://mysite.example.com/User%20Photos/Profile%20Pictures/useraccountnameThumb.jpg"/> |
And change it to:
1 |
<img src="http://myteam.example.com/_layouts/15/userphoto.aspx?size=S&url=http://mysite.example.com/User%20Photos/Profile%20Pictures/useraccountnameThumb.jpg"/> |
Source(s):
- https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebapplication.crossdomainphotosenabled.aspx