使用WSS对象模型从SPUser获取用户照片

4 sharepoint wss photo

我试图通过WSS 3.0对象模型在Sharepoint的用户照片上检索用户.我一直在浏览网页寻求解决方案,但到目前为止,我一直无法找到办法.是否有可能,如果是这样,怎么样?

Eri*_*ver 5

这是一个代码片段,可以帮助您完成工作.您可能需要进行一些额外的验证以避免任何异常(确保配置文件实际存在,确保图像URL实际存在等等):

    //get current profile manager
    UserProfileManager objUserProfileManager = new UserProfileManager(PortalContext.Current);
    //get current users profile
    UserProfile profile = objUserProfileManager.GetUserProfile(true);
    //get user image URL
    string imageUrl = (string)profile[PropertyConstants.PictureUrl];

    //do something here with imageUrl
Run Code Online (Sandbox Code Playgroud)