Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-08-31
1
Medium Priority
?
898 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflow…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

721 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