我试图获取确定用户财产的当前隐私状态。我没有什么奇特的想法,我只需要知道财产是如何配置的,以便我可以做出决定。这是我的代码:通过Sharepoint 2010获取财产隐私
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("http://sp2010dev:3767"))
{
context = SPServiceContext.GetContext(site);
psm = ProfileSubtypeManager.Get(context);
upm = new UserProfileManager(context, false);
UserProfile user = upm.GetUserProfile(false);
Privacy privacy = user["SPS-Skills"].Privacy;
}
});
我获得这个消息:拒绝访问:您可以精心取回自己的个人资料的隐私设置,除非你是管理员。
任何线索?
当您使用SPSecurity.RunWithElevatedPrivileges时,可以有效地将代码作为IIS AppPool用户运行。该用户是网站上的网站集管理员吗? – 2012-03-09 14:14:57
Nop,它是MySite。我正试图让一位同事隐私政策显示或隐藏该媒体资源。为了简单起见,我的代码示例中只有一名用户。 – 2012-03-09 14:17:12
如果yuo're击中mysite,考虑不与高架privs运行.. – 2012-03-09 14:32:59