Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

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

SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

885 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