With all the new social media features in SharePoint 2010 people have started getting serious about putting useful information about themselves into their profiles in SharePoint. The SharePoint interface makes it really easy for users to upload their pictures to really add that personal touch. Other Microsoft products have also jumped on the band wagon, namely Outlook 2010 and Exchange 2010. Normally people want to export the pictures from SharePoint back into Active Directory so that the other servers can use them. That is NOT what this blog post is about.
This blog post is about going the other direction. I’m going to walk through how to take pictures that are already in Active Directory and import them into SharePoint. This has come up a couple of times in the last month. I’ve had a couple of organizations that already had pictures in AD for use in Exchange and wanted to use those same pictures in SharePoint.
The first step is to verify that your SharePoint 2010 farm is at build number 14.0.5128.5000 or later. That’s the October 2010 CU. You can see a list of all the SharePoint 2010 build numbers and cumulative updates in this blog post. The functionality to import pictures from AD did not work before the October CU, so don’t even try if you don’t have that CU or later installed.
Here’s the before picture in My Profile:

Preparing AD
First we need to make there is a picture in Active Directory. To verify that open up ADSIEDIT.MSC on one of your domain controllers, and connect to the Default naming context if you’re not already. Then find one of the users and right click and select properties. Verify under Filter that “Show only attributes with values” is NOT checked. Then in the Attributes list scroll down to thumbnailPhoto and see if it has a value. If it does NOT have a value it will look like this:

If the value is set, then you can skip the next part where we prepare SharePoint. If your screen looks like the one above then you’ll need to get some pictures into AD before we can import them into SharePoint. Fortunately we can do this with PowerShell. You’ll need a picture of the person to import. It has to be a JPG image and it should be around 200 x 200 and under 10k. To make things easy, I’ve named the JPG exactly the same as the account name, so todd.jpg is the image for the account contoso\todd.
After you’ve created the JPG log on to a domain controller and open a PowerShell prompt. You’ll need to add the Active Directory module with this line:
Import-Module ActiveDirectory
Then we’ll load that JPG file into a variable. We have to cast it as a byte as that’s the type of object AD stores in that thumbnailPhoto property. The following line loads up the todd.jpg for us:
$picture = [byte[]](Get-Content c:\Pictures\Todd.jpg –Encoding byte)
Then we’ll use Set-ADUser to assign that variable to the user:
Set-ADUser todd –Replace @{thumbnailPhoto=$picture}
The whole thing looks like this:

If you go back in to ADSIEDIT.MSC you should now see a value for the thumbnailPhoto property. Repeat this for all the accounts you want to have pictures in AD and SharePoint.
Preparing SharePoint
Once AD is squared away we need to tell SharePoint to pull that picture in. Open Central Admin and go manage your User Profile Service Application. Click “Manage User Properties.” Scroll down to “Picture” click it and click Edit.

At the bottom you’ll need to define a new mapping to tell SharePoint where to import the picture from. Choose your domain connection from the Source Data Connection dropdown. Choose thumbnailPhoto as the attribute and Import as the direction, then click Add and Ok.

A couple of notes here. You can only map this in one direction. Either SharePoint is authoritive for this property or AD is, but you can’t go both ways. If you choose to import from AD any pictures in SharePoint will be removed and replaced by the value from AD. If the AD value is blank, then SharePoint will be blank. So be very careful with this. Also, you may want to remove the ability for users to upload their own pictures as they’ll just get overwritten by AD.
After you’ve got that all set up do a Full Profile Import in your User Profile Service.This will take a few minutes. You can watch the process with MIISCLIENT.EXE which can be found in “C:\Program Files\Microsoft Office Servers\14.0\Synchronization Service\UIShell” During the DS_FULLIMPORT step you should see some updates come in and if you click the user you added the picture to you should see FIM pick up that change.

If you do go into MIISCLIENT.EXE for goodness sake whatever you do don’t change anything!
Finishing up
You might think that’s all there is to it. Unfortunately there’s one final step. You need to tell SharePoint to take that image and resize it correctly for all the places it’s going to show that image. You do that with the PowerShell cmdlet Update-SPProfilePhoteStore. Here’s the full command:
Update-SPProfilePhotoStore –MySiteHostLocation http://my.contoso.com –CreateThumbnailsForImportedPhotos
That’ll take a minute to run through your photos.

Now when you view your profile you should see your own smiling face looking back at you.

As you add more pictures to AD users they’ll show up in SharePoint. You’ll probably need to run that Update-SPProfilePhotoStore cmdlet periodically to make sure all the sizes get created.
Enjoy another victory against the mean old User Profile Service.
tk