[英]Update Full Name in Forms Based Authentication
我將SharePoint 2013與基於表單的身份驗證一起使用。 我可以更新電子郵件,但不能從C#更新全名,該怎么辦?
(注意:不是我要更改的用戶名/登錄名,而是全名)。
我可以這樣更改電子郵件(和用戶名)。
public void ChangeEmail(string loginName,string email)
{
SPSecurity.RunWithElevatedPrivileges(() =>
{
using (SPSite site = new SPSite(_site.ID))
{
site.AllowUnsafeUpdates = true;
site.RootWeb.AllowUnsafeUpdates = true;
string emailUser = Utils.BaseMembershipProvider(site).GetUserNameByEmail(email);
if (!string.IsNullOrEmpty(emailUser) && emailUser != loginName)
{
throw new EmailAddressExists();
}
MembershipUser user = Utils.BaseMembershipProvider(site).GetUser(loginName, false);
if (user != null)
{
user.Email = email;
user.UserName = "I need to change the Full Name, not the username";
Utils.BaseMembershipProvider(site).UpdateUser(user);
}
}
});
}
您不能將其他屬性添加到用戶數據庫。 您所要做的就是將FBA用戶添加到SharePoint中,並在添加時提供其他參數(例如全名)。 此數據將保存在SharePoint中。
有關更多詳細信息,請參考SharePoint FBA Pack github頁面中的以下代碼。 https://github.com/Visigo/SharePointFBAPack/blob/master/Visigo.Sharepoint.FormsBasedAuthentication/Visigo.Sharepoint.FormsBasedAuthentication/Layouts/FBA/MANAGEMENT/UserNew.aspx.cs#L100
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.