i am Trying to update a user profile property value through the webpart. This works fine on Dev environment but on QA i get and error,
Attempted to perform an unauthorized operation. at Microsoft.Office.Server.UserProfiles.UserProfileValueCollection.CheckUpdatePermissions() at Microsoft.Office.Server.UserProfiles.ProfileValueCollectionBase.set_Value(Object value) at Blocked_listupdate.VisualWebPart1.VisualWebPart1UserControl.<>c_DisplayClass3.b_0() at Microsoft.SharePoint.SPSecurity.<>c_DisplayClass4.b_2() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at Blocked_listupdate.VisualWebPart1.VisualWebPart1UserControl.btnupdate_Click(Object sender, EventArgs e)
my code :
string socialDataStatsSite = url;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPSite siteColl = new SPSite(socialDataStatsSite);
SPWeb st = siteColl.OpenWeb();
// SPServiceContext serviceContext = SPServiceContext.GetContext(siteColl);
HttpContext.Current = null;
ServerContext serviceContext = ServerContext.GetContext(siteColl);
UserProfileManager manger = new UserProfileManager(serviceContext);
// UserProfile userProfile = ProfileLoader.GetProfileLoader().GetUserProfile();
UserProfile userProfile = manger.GetUserProfile(id);
// SPContext.Current.Web.AllowUnsafeUpdates = true;
siteColl.AllowUnsafeUpdates = true;
userProfile["SPS-StatusNotes"].Value = "default";
//userProfile[PropertyConstants.StatusNotes].Add(statusMessage);
userProfile.Commit();