我试图找回一个用户对Sharepoint的用户的照片通过的鞋3.0对象的模式。我已经浏览该网站解决方案,但到目前为止,我已经无法找到一种方法来这样做。它是可能的,并且如果这样如何?

有帮助吗?

解决方案

这是一段代码,应该帮助完成工作用于你。你可能需要做一些额外的验证,以避免任何例外情况(确保配置文件实际上存在,保证图像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

其他提示

如果你是严格说OZ3.0(而不MOSS),那么你真的没有全球的用户配置文件本身,而是一个hiddenh用户信息的列表中的每个网站集中。这意味着没有任何东西在Microsoft。办公室。服务器名称空间是提供给你。

然而,可以更新用户的信息表通过程序只要你知道URL于用户的图片。只要你在运行的用某种类型的提升的权限,则应该能够 操纵这个列表 就像你一样可以与任何其他SharePoint名单。记住,这个清单仅仅是良好的范围的一个网站集,使用户必须使这个同样的更新所有的地方实际上有照片的URL地址。加用户不能进入的信息的用户名单,直到有人将某种权限,因此并不是每一个用户,在您的领域将在那里。

清洁的方式来处理这绝对的用户配置文件的机制是MOSS,但如果这是选择的问题真的应该是更新的问MOSS vs的鞋子

啊,你有使用UserProfileManager类。更多信息: http://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.userprofilemanager.aspx

例使用:

public override void ItemAdded(SPItemEventProperties properties)
{
    // Get list item on which the event occurred.
    SPListItem item = properties.ListItem;

    // Set the Author Image field to the user's PictureURL if it exists.
    using (SPWeb web = properties.OpenWeb())
    {
        // Author: {C32DB804-FF2D-4656-A38A-B0394BA5C931}
        SPFieldUserValue authorValue = new SPFieldUserValue(properties.OpenWeb(), item[new Guid("{C32DB804-FF2D-4656-A38A-B0394BA5C931}")].ToString());

        UserProfileManager profileManager = new UserProfileManager(ServerContext.GetContext(web.Site));
        UserProfile profile = profileManager.GetUserProfile(authorValue.LookupId);
        UserProfileValueCollection values = profile[PropertyConstants.PictureUrl];

        if (values.Count > 0)
        {
            // Author Image: {37A5CA4C-7621-44d7-BF3B-583F742CE52F}
            SPFieldUrlValue urlValue = new SPFieldUrlValue(values.Value.ToString());
            item[new Guid("{37A5CA4C-7621-44d7-BF3B-583F742CE52F}")] = urlValue.Url;
        }
    }

    item.Update();

    // News Text: {7F55A8F0-4555-46BC-B24C-222240B862AF}
    //

    // Author Image: {37A5CA4C-7621-44d7-BF3B-583F742CE52F}
    // 

    // Publish Date: {45E84B8B-E161-46C6-AD51-27A42E4992B5}
    //
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top