-1

SharePoint 2010 makes greater use of the employee's photo. In my company, employee photos are managed by secretaries and are considered part of HR data. We have a handy web service that resizes and returns employees' photos according to login:

http://services.domain.com/photo.ashx?login=kobi&width=64&height=64

What is a good way to "rewire" all SharePoint photos to this service? I'd like to avoid uploading all photos to the /my site, or updating the Active Directory - I'm looking for an all-code solution.

Can I rewrite the part that displays the photo? If not, can rewrite all users' photos' urls?

Looks like SharePoint is using ProfilePropertyImage from Microsoft.SharePoint.Portal.dll - What I would really like to do is to make SharePoint use my control instead. Is that too optimistic?

Kobi
  • 135,331
  • 41
  • 252
  • 292

2 Answers2

2

There is a small STSADM script changing the user image URL with a custom URL and the user ID. It was made for Sharepoint 2007, but maybe it is an easy change for SP2010? Actually it even looks like one could make a little console application from it.

Maybe you're interested in a custom HTTP handler for user images (again Sharepoint 2007)?

For Sharepoint 2010 you might want to look into the User Profile Synchronization service, maybe you can attach your special image URL to the profiles somehow?

Dennis G
  • 21,405
  • 19
  • 96
  • 133
  • The first link seems like what I need, though if I understand correctly, requires running the command periodically for all employees. I'll look into that, thanks. I was hoping for a hook into SharePoint though... – Kobi Nov 03 '10 at 12:33
  • Well in the end it is hooking into Sharepoint, just using STSADM to run the command. By looking into the available Source I can see that all the code is doing is to set the "PictureURL": `(SetPicture(profile["PictureURL"], librarypath))` in `SetPictureUrlNewPath.cs`. Download page is here: http://stsadm.blogspot.com/2009/02/downloads.html If you want it to run automatically you could create a timer/schedule for your update command. – Dennis G Nov 03 '10 at 14:23
1

If you are using the UserProfiles with UserProfileManager then you can set this property manually when you import the profiles. You can set up your import from whatever system and then when you are creating the User Profile, simply set the PictureUrl field to be your custom URL. Rather than use the built-in profile syncronization you can use a batch job from a simple console application to have more control over the import. You can run this code from a .exe as part of a nightly profile update from various systems.

SPServiceContext serviceContext = SPServiceContext.GetContext(topSite);
UserProfileManager profileMgr = ProfileLoader.GetProfileLoader(serviceContext).GetUserProfileManager();
UserProfile curUser = null;
if (profileMgr.UserExists(userId))
{
    curUser = profileMgr.GetUserProfile(userId);
} 
else
{
    curUser = profileMgr.CreateUserProfile(userId);
}
//Set lots of other properties here
curUser[PropertyConstants.PictureUrl].Value = "http://services.domain.com/photo.ashx?login=" + userId + "&width=64&height=64";
curUser.Commit();

This will set the PicureUrl property to your custom URL and you don't have to upload all of the photos.

Peter Jacoby
  • 2,406
  • 25
  • 26