-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?

4

2 回答 2

2

有一个小的 STSADM 脚本使用自定义 URL 和用户 ID 更改用户图像 URL。它是为 Sharepoint 2007 制作的,但对于 SP2010 来说可能是一个简单的更改?实际上,它甚至看起来可以用它制作一个小控制台应用程序。

也许您对用户图像的自定义 HTTP 处理程序感兴趣(同样是 Sharepoint 2007)?

对于 Sharepoint 2010,您可能想要查看用户配置文件同步服务,也许您可​​以以某种方式将您的特殊图像 URL 附加到配置文件?

于 2010-11-03T11:58:09.337 回答
1

如果您将 UserProfiles 与 UserProfileManager 一起使用,则可以在导入配置文件时手动设置此属性。您可以从任何系统设置导入,然后在创建用户配置文件时,只需将 PictureUrl 字段设置为您的自定义 URL。您可以使用简单控制台应用程序中的批处理作业来更好地控制导入,而不是使用内置的配置文件同步。作为来自各种系统的夜间配置文件更新的一部分,您可以从 .exe 运行此代码。

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();

这会将 PicureUrl 属性设置为您的自定义 URL,您不必上传所有照片。

于 2010-11-03T21:02:00.617 回答