Updates to a user’s profile properties can be performed with the following:
SPSite site = SPContext.GetContext(HttpContext.Current).Site;
ServerContext serverContext = ServerContext.GetContext(site);
UserProfileManager profileManager = new UserProfileManager(serverContext);
UserProfile currentUserProfile = profileManager.GetUserProfile(System.Web.HttpContext.Current.User.Identity.Name);
if (this.chkTerms.Checked)
currentUserProfile["TermsOfUseAccepted"].Value = "true";
else
currentUserProfile["TermsOfUseAccepted"].Value = "false";
currentUserProfile["SecurityQuestion1"].Value = this.lstQuestion1.SelectedItem.Text + "|" + Server.HtmlEncode(this.txtQuestion1Ans.Text);
currentUserProfile["SecurityQuestion2"].Value = this.lstQuestion2.SelectedItem.Text + "|" + Server.HtmlEncode(this.txtQuestion2Ans.Text);
currentUserProfile["SecurityQuestion3"].Value = this.lstQuestion3.SelectedItem.Text + "|" + Server.HtmlEncode(this.txtQuestion3Ans.Text);
currentUserProfile.Commit();
site.RootWeb.Dispose();
site.Dispose();
0 Comments.