Importing AD Employee Photos into SharePoint User Profiles
Posted by Clayton James on May 8, 2009
I was recently asked to provide a process for importing Employee pictures into SharePoint so they would show up in search results and various OOTB web parts. This particular client has MOSS but doesn’t use My Sites.
This post by Henry initially helped me out.
They didn’t want the individual users to have the abilty to upload their own photo’s or modify them in any way, this was to be managed by IT.
- Create a Picture Library in your Intranet. This will store the photo’s for each employee. When storing employee photo’s chose the filename carefully if you want to populate the AD using scripts. I use something like cjames.jpg which is a correlation to the users account name.
- In Active Directory choose an AD property that will be mapped to your SharePoint User Profile Property. In my case I selected the extensionAttribute1 field that is located in the ExchangedAdvanced tab ((note this field may not show up if the Exchange Mgt Console hasn’t been installed)
- Populate this field with the URL to the employee’s photo that is in the Picture Library e.g http://sitename/ProfilePhotos/CJames.jpg (look below for a script example)
- In SharePoint SSP┬áclick the┬áUser Profiles and Properties link
- Click the View Profile Properties under the heading User Profile Properties
- Find the Picture property and select the Edit menu item
- Make note of the Usage: Number of profiles using this property. This should increase after we complete a full import
- At the bottom of the screen make sure Master Connection is selected and in the Datasource field to map select extensionAttribute1 (note: this field may not show up if the Exchange Mgt Console hasn’t been installed)
- Click Ok
- Complete a StartFull Import
- Once the full import is complete go back into the the Picture property and again check the Usage:Number of profiles that use this property. This should now contain some values.
- Verify this by viewing an Employee’s profile and the Picture property
Some things I had issues with:
- Make sure your Import Connection service account has “Manage User Profile” permissions
- May need to execute a Full Search crawl once photos are uploaded in the Picture Library
I also wrote a script to populate the AD extensionAttribute1 field as there were over 1000 employee’s and no one put their hand up for this job. The import thing here was for employee photo images to have a one to one mapping with their login account name (samaccountname). The person who runs this script also needs certain permissions in AD to update AD accounts. I would initially comment out the┬áOn Error Resume Next so you see if your account has enough privleges or not.
The script is very limited but hopefully it may provide some insight.
‘On Error Resume Next
Set objParent = GetObject(“LDAP://OU=Users,OU=Austraila,OU=Offices,OU=AU,DC=domain,DC=local“)
objparent.Filter = Array(“user”)
for each objUser in objParent
┬á Wscript.Echo “Modifying ” & objUser.Get(“samaccountname”)┬á
┬á objUser.put “extensionAttribute1”, “http://sitename/ProfilePhotos/” & objUser.Get(“samaccountname”) & “.jpg”
Now, IT┬áare responsible whenever they create a new account they must also populate the extensionAttribute1 field with the URL of the picture library and the employee’s picture filename will always be their account name.