首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >以用户配置文件管理员身份管理SP2010用户配置文件

以用户配置文件管理员身份管理SP2010用户配置文件
EN

Stack Overflow用户
提问于 2011-08-11 05:30:23
回答 1查看 2K关注 0票数 1

我有一个SharePoint 2010事件接收器,需要更新网站上的另一个用户的用户配置文件,即不是触发事件的用户。我尝试使用用户配置文件管理员的用户令牌(如another question中所建议的)打开UserProfileManager,但由于某些原因,它仍然在触发事件的人的帐户下运行。

模拟User profile Service应用程序管理员以便我可以编辑任何用户的配置文件的正确方法是什么?

代码语言:javascript
复制
SPUserToken upmToken = web.AllUsers[@"domain\upadmin"].UserToken;//this user is a User Profile Service Application Administrator
using (SPSite upmSite = new SPSite(web.Url, upmToken))
{
    SPServiceContext context = SPServiceContext.GetContext(upmSite);
    UserProfileManager userProfileManager = new UserProfileManager(context, false);
    UserProfile userProfile = userProfileManager.GetUserProfile("anotheruser");
    userProfile["PictureUrl"].Value = pictureUrl;//System.UnauthorizedAccessException: Attempted to perform an unauthorized operation
    userProfile.Commit();
}

如果我将自己添加到User Profile Service Application Administrators,则代码运行良好,因此它显然仍在尝试在触发事件接收器的用户的帐户下打开UserProfileManager。

我不认为为了使用RunWithElevatedPermissions而将应用程序池帐户添加到用户配置文件管理员是不可接受的。

EN

回答 1

Stack Overflow用户

发布于 2013-07-27 04:18:03

您是否尝试过使用系统帐户令牌(SPUserToken.SystemAccount)?使用(SPSite mySiteSite =新SPSite(mySiteHostUrl,SPUserToken.SystemAccount))

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7018094

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档