Wednesday, July 25, 2012

SharePoint profile image sync issue.


The SharePoint farm I manage is configured to sync the pictures from SharePoint user profile to AD. Everything was working like a charm until we decided to upload pictures from an internal social media system in which users have profile images uploaded to SharePoint for users with no images in their profile.  I updated the pictures using a powershell script and ran Update-SPProfilePhotoStore command. I started getting the following errors in the event log and the Profile Synchronization Service manager:
Synchronization service Manager Error – MOSS_DELTAIMPORT_GUID stopped-extension-dll-exception
Event Log:
Event ID : 6801
Source: FIMSynchronizationService
The extensible extension returned an unsupported error.
 The stack trace is:

 "System.Net.WebException: The remote server returned an error: (404) Not Found.
   at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
   at System.Net.WebClient.DownloadData(Uri address)
   at Microsoft.Office.Server.UserProfiles.ManagementAgent.ProfileImportExportExtension.DownloadPictures(ProfileChangeData[] profiles)
   at Microsoft.Office.Server.UserProfiles.ManagementAgent.ProfileImportExportExtension.Microsoft.MetadirectoryServices.IMAExtensibleFileImport.GenerateImportFile(String fileName, String connectTo, String user, String password, ConfigParameterCollection configParameters, Boolean fFullImport, TypeDescriptionCollection types, String& customData)
Forefront Identity Manager 4.0.2450.34"

After trying multiple things and Googling, I came to the conclusion that the error was due to few rouge images which SharePoint could not convert. The problem was that I did not know the user with the problematic image. So, I first got a list of all images from “User Photo” library in the My Site host


$site = Get-spsite “http://mysitehost”
$web = $site.RootWeb
$list = $web.Lists["User Photos"]
$Folders = $list.RootFolder.SubFolders
foreach ($Folder in $Folders)
{
     if ($Folder.Name -ne "Forms")
     {          foreach ($item in $Folder.Files)           {               $item.Name          }     }
}
$web.Dispose();
$site.Dispose();

And then I listed down all users who had their profile images set using the script below:


$site = Get-SPSite "http://mysitehost " $ServiceContext = Get-SPServiceContext($site); $upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($servicecontext)$upm.GetEnumerator() | foreach{     $pictureURL = $_["PictureURL"].Value           if (($pictureURL -ne "") -and ($pictureURL -ne $null))           {                     $_["AccountName"].Value           }}


After manipulating the results from both the scripts using excel to find the unique user ids, I found that couple of users had their “PictureURL” property set but did not have the corresponding mthum.jpg, lthumb.jpg and sthumb.jpg files. I came to the conclusion that these were the users who had the offending images, since the system could not create the corresponding images from the source image.  Next, I set the “PictureURL” property for these 2 users to blank and started sync again. Viola, it synced the images without any issue.

2 comments:

Unknown said...

Thank you soooo much! You saved me from having to delete everyone's profiles and start again!

Unknown said...

Thank you so much for your post! You saved me from a big mess of deleting profiles.
I used your trick and found two users with bad links. Deleted the users and bam!