Updates the database with changes made to the properties of the user object.
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Sub Update
用法
Dim instance As SPUser
instance.Update()
public void Update()
异常
| 异常 | 条件 |
|---|---|
| SPException | The user is a site collection administrator or site collection auditor. -or- The properties can only be set for an application principal. |
备注
Call this method after setting the values for the properties of the user object to save the changes in the database.
示例
The following code example modifies the e-mail address, display name, and notes for a specified user object.
Dim siteCollection As SPSite = SPControl.GetContextSite(Context)
Dim site As SPWeb = siteCollection.AllWebs("Site_Name")
Dim user As SPUser = site.AllUsers("User_Name")
user.Email = "E-mail_Address"
user.Name = "Display_Name"
user.Notes = "User_Notes"
user.Update()
SPSite oSiteCollection = SPContext.Current.Site;
using (SPWeb oWebsite = oSiteCollection.AllWebs["Website_Name"])
{
SPUser oUser = oWebsite.AllUsers["User_Name"];
oUser.Email = " E-mail_Address";
oUser.Name = " Display_Name";
oUser.Notes = " User_Notes";
oUser.Update();
}
备注
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.