SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to know how to get the Property Privacy settings when the user changed from "MY Manager" to "My colleague" in edit profile page ?

I am able to get the Default privacy value, but i want user-specific Privacy settings value for specific property.. ? How can i achieve this ?

share|improve this question
could you say what approach you have in mind (programmatically - event handling, powershell,etc.) ? – Supriyo SB Chatterjee Apr 16 '12 at 20:30

I got this using SharePoint API. Find the following code.

        string privacyvalue = string.Empty;
        SPUser AdminUser = SPContext.Current.Web.AllUsers[@"SHAREPOINT\SYSTEM"];
        var superToken = AdminUser.UserToken;
        HttpContext con = HttpContext.Current;
            using (SPSite site = new SPSite(SPContext.Current.Site.Url, superToken))
                SPServiceContext context1 = SPServiceContext.GetContext(site);
                HttpContext.Current = null;
                UserProfileManager upm = new UserProfileManager(context1, false);
                this.userProfile = upm.GetUserProfile(this.UserAccount);
                Privacy privacy = this.userProfile[PropertyName].Privacy;
                privacyvalue = privacy.ToString();
       HttpContext.Current = con;
share|improve this answer
to get the systemaccount you should just use SPContext.Current.Site.SystemAccount and also if you want to update or commit the userprofile you should use System.Security.PermissionSet ps = new System.Security.PermissionSet(System.Security.Permissions.PermissionState.Unrest‌​ricted); ps.Assert(); – Jalali Shakib Jun 30 '12 at 4:32
Can you please mark this as your answer (to put the question in correct state)? :) – Robert Lindgren Jan 15 '14 at 7:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.