How to: Set Privacy Policies for User Profile Properties

Applies to: SharePoint Server 2010

Microsoft SharePoint Server 2010 enables you to set privacy policies on user profile properties, memberships, colleagues, and the like, to restrict who can view and edit personal information.

The Default Privacy policy limits the visibility of properties, users' My Documents, and other My Site content to:

  • Private [Only Me]

  • Manager [Me and my manager]

  • My Workgroup [Organization]

  • My Colleagues [Contacts]

  • Public [Everyone]

The Privacy Policy specifies whether providing a value for a property is mandatory, disabled, or optional. Privacy Policy is only applicable to user profile properties.

The following code example shows you how to set the privacy of a property. Replace servername and Hobbies with actual values before running the code example. Also add references to the following in your Microsoft Visual Studio project:

  • Microsoft.Office.Server

  • Microsoft.Office.Server.UserProfiles

  • Microsoft.SharePoint

  • System.Web


using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Server;
using Microsoft.Office.Server.Administration;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
using System.Web;

namespace UserProfilesApp
    class Program
        static void Main(string[] args)

            using (SPSite site = new SPSite("http://servername"))
                SPServiceContext context = SPServiceContext.GetContext(site);
                ProfileSubtypeManager psm = ProfileSubtypeManager.Get(context);
                ProfileSubtype ps = psm.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User));
                ProfileSubtypePropertyManager pspm = ps.Properties;
                ProfileSubtypeProperty p = pspm.GetPropertyByName("Hobbies");
                p.DefaultPrivacy = Privacy.Manager;
                p.PrivacyPolicy = PrivacyPolicy.OptIn;


See Also


How to: Create and Edit a User Profile Property

How to: Create Multivalue Properties

How to: Set Multiple Values to a Multivalue Property

How to: Change Profile Properties

How to: Create Taxonomical Multivalue Properties