Skip Ribbon Commands
Skip to main content

Anders Rask on SharePoint

:

Anders Rask on SharePoint > Posts > Using regional Locale on your My Site host breaks user profile thumbnails
August 31
Using regional Locale on your My Site host breaks user profile thumbnails
Working with SharePoint sometimes has its challenges. Especially so if you work with regional versions of SharePoint - sometimes you do get the impression that testing different regional settings haven't had top priority in Redmond :-O
 
The most recent evidence I found on this was yesterday when I tried generating thumbnails for user profile pictures that I had added to Active Directory: It turns out that the PowerShell cmdlet you use to generate the 3 differently sized thumbnails used throughout SharePoint looks at the locale of the My Site host when it decides where to look for the image that the User Profile Synchronization copy to My Site host.
 
In short, when FIM detects a new image is present in AD, it copies that picture to the My Site host with the naming syntax <userProfileManager.PartitionID>_<userProfile.recordId>.jpg (note that PartitionID is an internal property, so you cannot look this property up without using reflection or similar, recordID is the numeric ID of a user in User Profiles -not SPUser id).
 
The location FIM copy the files to, is <mysitehost>/User Photos/Profile Pictures/ for an english My Site host, for a site from another region, for example Denmark, the images are uploaded to <mysitehost>/User Photos/Profilbilleder/. Note that the URL of the picture gallery is the same as with the english site. This is how most "system libraries" are handled in SharePoint -another example is Style Library that also keeps the URL even though the title are translated to the appropriate language.
 
To get SharePoint to generate thumbnails you now need to run a PowerShell cmdlet called Update-SPProfilePhotoStore with the undocumented parameter CreateThumbnailsForImportedPhotos to force it to generate thumbnails even if thumbnails are already present:
 
Update-SPProfilePhotoStore -MySiteHostLocation http://my.intranet -CreateThumbnailsForImportedPhotos $true
 
This is where the problems start for non-english My Site hosts: the code in Update-SPProfilePhotoStore checks the locale of the root site, and fetches a translated string from a ressource file and uses that as the URL, so when you try to generate thumbnails nothing happens, because it looks in the wrong folder!
 
I confirmed this by decompiled MicroSoft.Office.Server.UserProfiles.dll where the cmdlet is located (TIP: Get-Command Update-SPProfilePhotoStore | select DLL, ImplementingType will get you both DLL and class used), set a break point inside the internal sealed class SPCmdletUserProfilePhotoStore and attached a debugger to my Powershell.exe thread.
 
As you can clearly see the cmdlet was looking for my image in the wrong location: "Brugerfotos" is danish for "User Photos", so the cmdlet wrongly assumes that the user photo directory has a translated URL -which it doesnt!
 
I have created a workaround to fix this bug: After UPS finished synchronizing, I move any files from User Profile to a new temporary document library "Brugerfotos", and then run the cmdlet to generate thumbnails.
 
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Add-PSSnapin "Microsoft.SharePoint.PowerShell" -EA 0
 
function Repair-SPProfilePhotoStore
 {
 [CmdletBinding(SupportsShouldProcess = $true)]
 param
 (
 [Parameter(Mandatory = $true)]
 [string] $LocalizedUserPhotosName,
 [Parameter(Mandatory = $true)]
 [string] $LocalizedProfilePicturesName,
 [Parameter(Mandatory = $true)]
 [string] $MySiteHostLocation
 )
 
process
 {
 $assigments = Start-SPAssignment
 
$mySite = $assigments | Get-SPWeb $MySiteHostLocation -EA 0
 if ( -not $mySite )
 {
 Write-Error -Message "Failed to fetch MySite from location [$MySiteHostLocation]." -Category ObjectNotFound
 return
 }
 #check if temp list exists:
 $tempUserPhotos = $mySite.Lists.TryGetList("tempUserPhotos")
 
if ( $tempUserPhotos -eq $null )
 {
 $mysite.Lists.Add("tempUserPhotos", "Used to temporarily store user photos for thumbnail generation due to bug in Update-SPProfilePhotoStore", $LocalizedUserPhotosName,"",109,101) | Out-Null
 $tempUserPhotos = $mySite.Lists.TryGetList("tempUserPhotos")
 $tempUserPhotos.RootFolder.SubFolders.Add($LocalizedProfilePicturesName)
 }
 
# get hold of User Profile Manager
 $upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager ((Get-SPServiceContext $MySiteHostLocation))
 if ( -not $upm )
 {
 Write-Error -Message "Failed creating UserProfileManager object from context [$MySiteHostLocation]. Check permissions on User Profile Manager." -Category ObjectNotFound
 return
 }
 
# partitionId is an *internal* property on UserProfileManagerBase. It is used here for naming temporary profile photos that FIM copies to User Photos
 [Reflection.BindingFlags]$flags = [Reflection.BindingFlags]::NonPublic -bor [Reflection.BindingFlags]::Instance
 $partitionID = $upm.GetType().BaseType.GetProperty("PartitionID",$flags).GetValue($upm,$null)
 
if ( -not $partitionID )
 {
 Write-Error -Message "Could not find internal property PartitionID" -Category ObjectNotFound
 return
 }
 
#get UserPhotos list
 $userPhotos = $mySite.Lists.TryGetList($LocalizedUserPhotosName)
 if ( -not $userPhotos )
 {
 Write-Error -Message "Could not find User Photos list named $LocalizedUserPhotosName" -Category ObjectNotFound
 return
 }
 
# get photos that start with PartitionID from source directory and copy them to destination directory
 $photos = $userPhotos.Items | ? { $_.Name -like "$partitionID*.jpg"}
 
if ( $photos )
 {
 $photos | % { $tempUserPhotos.RootFolder.Files.Add("$($tempUserPhotos.RootFolder)/$LocalizedProfilePicturesName/$($_.Name)", $_.File.OpenBinaryStream()) | Out-Null }
 
# clean up temp files from FIM
 $photos | % { $_.Delete() }
 }
 
Stop-SPAssignment $assigments
 }
 }
 
Repair-SPProfilePhotoStore -LocalizedUserPhotosName "Brugerfotos" -LocalizedProfilePicturesName "Profilbilleder"  -MySiteHostLocation http://my.intranet
 Update-SPProfilePhotoStore -MySiteHostLocation  http://my.intranet -CreateThumbnailsForImportedPhotos $true
 
Save the above to a PS1 file and run it when your synchronization has finished.
 
NOTE: Remember that the user who run the script with needs permissions to both My Site host (full control) and User Profile Service Application (Full Control in Connection Permissions, not administrators). Being SPShell Admin is probably a good idea too, though I havent checked if it is a requirement...
 
I first experienced this bug after upgrading from April CU to SP1 and then June refresh, but according to Spence Harbar the bug has been around for a while.
 
Update: I checked the relevant classes and methods in August 2011 CU, and even though the KB claims that several localization bugs was fixed in this hotfix, the bug is still there: the list URL is translated to the regional culture, though it always has url USER%20PHOTOS no matter what language pack is installed.
 
For more details on adding user profile photos to Active Directory and synchronizing back to SharePoint, read Todd Carters excellent post on the subject here.

Comments

wow

Hey There. I found your weblog the use of msn. This is a really smartly written article. I'll make sure to bookmark it and return to learn extra of your helpful info. Thanks for the post. I'll certainly comeback. https://www.dissertationwritinguk.co.uk/write-my-dissertation
 on 7/4/2018 8:01 AM

Working with SharePoint

Working with SharePoint sometimes has its challenges. Especially so if you work with regional versions of SharePoint - sometimes you do get the impression that testing different regional settings haven't had top priority in Redmond. unblocked games https://unblockedgamestop.weebly.com
 on 9/20/2018 3:48 AM

Informative Coding

This is an extremely astutely composed article. I'll make a point to bookmark it and come back to learn additional of your supportive information. A debt of gratitude is in order for the post. I'll absolutely rebind.
https://britisheditors.co.uk/dissertation-editing-services.php
 on 11/22/2018 6:44 PM

Re: Using regional Locale on your My Site host breaks user profile thumbnails

How can we work on these posts as if there are things on https://www.topreviewstars.com/best-essay-writing-services/? I think that it will continue to do something more that we all need here for it.
 on 1/10/2019 7:03 AM

Reviews

This information gives the light inside we can observe the actuality. This is very nice a single and provides in-depth data. Thanks just for this nice write-up. https://www.moviesjacket.com/captain-marvel-jacket
 on 1/15/2019 4:24 AM

Reviews

Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. https://www.hjackets.com/blog/captain-marvel-costume/
 on 1/15/2019 4:58 AM

Re: Using regional Locale on your My Site host breaks user profile thumbnails

This is a brilliant article I truly value your work I continually fascinating to visit your post. Much obliged to you for some other enlightening site. https://www.filmstarlook.com/product/tv-series-yellowstone-cole-hauser-black-jacket/
 on 2/15/2019 12:50 AM

Lucas Till Jacket

I checked the relevant instructions and techniques in August 2011 CU, and despite the fact that the KB claims that several localization bugs
 on 3/29/2019 2:45 AM

Trendhoop Online Jacket

I observed your weblog using msn. This is a really neatly written article. https://www.amazon.com/TrendHoop-Lambskin-Leather-Distressed-Motorcycle/dp/B07LH1X29Q
 on 3/29/2019 2:47 AM

Alpha Titan

Alpha Titan ", but when a https://prowritingpartner.com/payforessay-net-review/ woman says that each one men are bad, this is not likely take place, at the least in mainstream society.This is in component because of the fact that men (specially white guys) are often seen as being "privileged' and having all of the power, that is then why it is perfect to deal with them badly. Primarily based on this, it is as even though girls are powerless youngsters and guys are adults .
 on 4/1/2019 12:24 PM
1 - 10Next

Add Comment

Title


Body *


Migrated Source URL


Commentator Name


Commentator Email


BotCheck *


Are you human? What is the sum of fifty-two minus ten?

Attachments