Solved

MS SharePoint 2010 - Using Object Model to read user profile property privacy.

Posted on 2010-08-31
1
832 Views
Last Modified: 2012-05-10
I am using the SP object model to query the user profile to render the contents in a custom web part. Retrieving the value stored in each property is simple enough, however I seem to be unable to retrieve the Privacy setting on the property as set by the user under the "Show To" column in "Edit My Profile".

The code below demonstrates how to manipulate the DefaultPrivacy, but I am after the "ActualPrivacy" that the user set, the "ActualPrivacy" overrides the "DefaultPrivacy"

 
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;

                p.Commit();



            }

        }

    }

}

Open in new window


Any help much appreciated.
0
Comment
Question by:maaknplan
1 Comment
 

Accepted Solution

by:
maaknplan earned 0 total points
Comment Utility
The "Actual Privacy" is stored in the UserProfileValueCollection class.

http://msdn.microsoft.com/en-us/library/ms566378.aspx

0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now