我試圖獲取確定用戶財產的當前隱私狀態。我沒有什麼奇特的想法,我只需要知道財產是如何配置的,以便我可以做出決定。這是我的代碼:通過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