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 ?

  • could you say what approach you have in mind (programmatically - event handling, powershell,etc.) ? Apr 16, 2012 at 20:30

1 Answer 1


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;
  • 1
    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.Unrestricted); ps.Assert(); Jun 30, 2012 at 4:32
  • Can you please mark this as your answer (to put the question in correct state)? :) Jan 15, 2014 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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