Skip Ribbon Commands
Skip to main content

Quick Launch

Todd Klindt's home page > Todd Klindt's Office 365 Admin Blog > Posts > Importing Profile Pictures from Active Directory to SharePoint 2010
February 01
Importing Profile Pictures from Active Directory to SharePoint 2010

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:

image

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:

SharePoint 2010 2-1-2011 9.22.37 PM

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:

SharePoint 2010 2-1-2011 9.51.36 PM

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.

SharePoint 2010 2-1-2011 9.55.32 PM

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.

image

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.

image

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.

image

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

SharePoint 2010 2-1-2011 10.19.52 PM

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

Comments

Informative Post

Thanks for the information. We are deploying MySites with hopeful integration into Project Server 2010.
 on 2/7/2011 8:30 PM

jpegPhoto instead?

Hi - Any idea why jpegPhoto isn't in the list?  We don't use thumbnailPhoto.
 on 2/14/2011 1:47 PM

Cool Stuff Todd - actually one of my co-workers at CDW found this

Tucking this one away as well
 on 3/4/2011 8:50 AM

Is there a way to pull in extendedattributes?

Moss 2007 use to allow us to import extendedattribute pictures into sharepoint. This functionality is gone with 2010. Do you know of a workaround.
 on 3/7/2011 10:27 AM

Re: Is there a way to pull in extendedattributes?

I don't know of any way to do this in SharePoint 2010, but I haven't ever looked. I do know you can create BCS connections and link them to users and pull in other attributes that way. I'm not sure if that helps you or not. I'm also not sure if you could create a secondary LDAP connection to your AD and pull your extendedattributes in that way.

Sorry. :(

tk
Todd O. KlindtNo presence information on 3/9/2011 3:20 PM

Thank you

Wow dude! You are amazing. I was pulling my hair out regaring this. Now my hair has started growing back again. Thanks to you
 on 4/28/2011 7:26 PM

Re: Thank you

You are very welcome. Glad it helped. It's good news for your barber too.

tk
Todd O. KlindtNo presence information on 5/3/2011 10:51 AM

An x is displayed instead of the image

I investigated and found out that the image url is missing a '/' after the my site host site collection url. e.g.
http://<mysitehosturl>%20Photos/Profile%20Pictures/<domain>_<username>_MThumb.jpg

is showing up instead of

http://<mysitehosturl>/%20Photos/Profile%20Pictures/<domain>_<username>_MThumb.jpg

Any ideas how to fix this or what I missed?
 on 6/9/2011 9:04 AM

re: An x is displayed instead of the image

I talked to this reader and I *think* the problem is caused by their MySite host site collection being in an odd spot. In most cases the MySite host is at the root of the web app, something like this; http://mysite.company.com. In other cases the MySite is in another web app in an explicit managed path, like this: http://portal.company.com/mysite. In this case the MySite Host was in the same wildcard managed path as the MySites themselves, like this; http://portal.company.com/personal/mysite. I've never seen that before. I'm not sure if that was contributing to the problem or not, but it's my first guess.

tk
Todd O. KlindtNo presence information on 6/25/2011 10:50 AM

Thanks

Steps worked perfectly, as always. Note that you can verify the pictures are being uploaded by going to http://{mysitehosturl}/User%20Photos/Forms/AllItems.aspx
 on 7/14/2011 10:05 AM
1 - 10Next

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


Today's date *

Select a date from the calendar.
Please enter today's date so I know you are a real person

Twitter


Want a message when I reply to your comment? Put your Twitter handle here.

Attachments

 

 SysKit