I’m trying to get the current privacy status for a determine user’s property. I’m doing nothing fancy, I just need to know how the property is configured so I can take decisions. This is my code:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite("http://sp2010dev:3767"))
{
context = SPServiceContext.GetContext(site);
psm = ProfileSubtypeManager.Get(context);
upm = new UserProfileManager(context, false);
UserProfile user = upm.GetUserProfile(false);
Privacy privacy = user["SPS-Skills"].Privacy;
}
});
I obtain this message: Access Denied: You may inly retrieve your own profile’s privacy setting, unless you are an administrator.
Any clue?
strange!!! its should be work your code. don’t know why its not running?
you should try this
Hops this helps.