Solved

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

Posted on 2010-08-31
1
892 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

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

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

0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Scenario: Let’s say you have a quote worksheet in Excel that you use to work up sales figures and such for your clients. You utilize SharePoint to manage and keep track of these documents. You would like values from your worksheet to populate Sh…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

624 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