Mapping Active Directory thumbnailPhoto to SharePoint Pictures

There was recently a push to get user photos into our SharePoint implementation. There was also a desire to have IT be involved with this process in order to ensure people actually have their photos online.

Surely, I don't want to do 400 people by hand, so naturally, we try and create a procedure and automate a little bit of it. I'm sure we could get this completely implemented, but for how low impact this change was, partial automation is perfectly fine.

Below is a web-ified version of the internal process document that I'll be supplying to my internal staff in order to make sure we all can perform this basic task when needed.

I also reference an amazing little utility called the Batch Picture Resizer below (PhotoResizeK10ICO.exe). For those who are interested, check out this utility over at A huge thanks to them for an amazing utiltity that has an infinite amount of uses. It is one of the staples in my tool set.

Hopefully this helps someone out in the future!

Updating User Photo


This document will define the steps needed to convert a user’s picture into the thumbnailPhoto attribute in Active Directory as well as synchronize this change into SharePoint.

Steps Required

Take the Picture

Take the photo in ‘Square’ mode. This is the format used by the system and will provide an easier transition into the directory. Focus on a ‘head shot’ including shoulders for consistency.
Once the picture is taken, upload the file to the following folder: \\my.domain\crp\CompanyFiles\Public\PhoneCards\users

Name the file in the format of ‘first initial + last name’ that coincides with the user’s email address. IE mriston.jpg for Mike Riston.

Preparing the .jpg

First, copy the picture to the \orig\ folder to preserve a full-definition copy in case tweaks are needed in the future.

Domain Admins Only: Drag the photo (mriston.jpg in our example) onto PhotoResizeK10ICO.exe in the working folder noted above. This will downsize the image so that it is approximately 10KB in size. This is a requirement for the image to fit appropriately into Active Directory.

NOTE: Sometimes, this image will actually make a new file in the folder. It will be similarly named like mriston-K10.jpg. Simply delete the orig mriston.jpg and rename mriston-K10.jpg to mriston.jpg. For the next step to properly function, the file needs to be in the format of .jpg

Uploading the Image into Active Directory

Domain Admins Only: Make a new .ps1 file and copy the contents below into it. Save the file and name is Upload User Photos.ps1

Import-Module ActiveDirectory 

$targets = gci \\my.domain\crp\CompanyFiles\Public\PhoneCards\users\*.jpg

foreach ($user in $targets) {
    #Update AD
    $useraccount = Get-ADUser $user.BaseName
    Write-Host Now working with $useraccount.samaccountname
    #read-host go?
    $photo = [byte[]](Get-Content $user -Encoding byte)            
    Set-ADUser $useraccount -Replace @{thumbnailPhoto=$photo}
    Move-Item $user ($user.DirectoryName+"\uploaded\")

    Remove-Variable -Name useraccount
    Remove-Variable -Name photo


Now, Right Click on Upload User Photos.ps1 and select ‘Run With PowerShell’. This needs to be performed on a computer with at least PowerShell v2.0 and the Remote Server Administrative Tools installed with Active Directory Module for PowerShell enabled and available.

This script will convert each file to a byte-code version of the photo, and inject it into the thumbnailPhoto attribute of the user whose name was in the filename. It will then move this file into the /uploaded/ folder so that the same photo is not processed again, yet is still preserved in the case it needs to be re-uploaded.

Updating SharePoint

Now that the photo is in Active Directory, we need to get the photo into SharePoint so that it appears during phone list results or inside of the Org Browser. This will happen automatically over time, however it is possible to force this process to take place immediately.

Domain Admins Only: Open up Internet Explorer and proceed to SharePoint Central Administration -- Application Management -- Service Applications -- Manage Service Applications -- User Profile Service Application.

Under the Synchronization section, you need to select Start Profile Synchronization. Select the option to utilize an Incremental Synchronization Press Start.

Now traverse to http://sp13app01/_admin/Timer.aspx and refresh the page until you see the User Profile Service Application – User Profile Incremental Syncrhonization proceeds and completes.

Now, remote desktop into SP13APP01 and log in as my-domain\SPS_FARM

On the desktop is a file called Update User Photos.ps1 with the contents of:
Import-Module 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\sharepoint.ps1' -Verbose

Update-SPProfilePhotoStore -CreateThumbnailsForImportedPhotos 1 -MySiteHostLocation -Verbose

new-item c:\users\sps_farm\desktop\log.log -itemtype file
[String]$arr = "Hey we did this on "
$date = get-date -DisplayHint DateTime

$arr = $arr + $date

$arr | out-file c:\users\sps_farm\desktop\SP_UserPicture_Sync.log –Append -Force 

Right click this file and select Run With PowerShell. It will process for about one minute and close out.

Confirming the Photo Upload

Simply do a person search to confirm the photo. Refresh the page a few times to ensure it queries for the new photo.


Configuring the ActiveDirectory thumbnailPhoto รจ SharePoint Picture mapping.

Log into SharePoint Central Administration

Traverse to Application Management -- Service Applications -- Manage Service Applications -- User Profile Service Application

On the next screen, select People -- Manage User Properties.

Find the Picture Property and select Edit

Scroll down to the Add New Mapping section and configure it as follows:

  • Source Data Connection : My-Domain LDAP Connection
  • Attribute : thumbnailPhoto
  • Direction : Import

Press Add & Save. Your SharePoint will now add pictures from ActiveDirectory into its Picture field.


Popular Posts