FormsAuthenticationUserCollection.Set(FormsAuthenticationUser) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
修改集合所包含的指定 FormsAuthenticationUser 物件。
public:
void Set(System::Web::Configuration::FormsAuthenticationUser ^ user);
public void Set (System.Web.Configuration.FormsAuthenticationUser user);
member this.Set : System.Web.Configuration.FormsAuthenticationUser -> unit
Public Sub Set (user As FormsAuthenticationUser)
參數
必須變更的 FormsAuthenticationUserCollection 物件。
範例
下列程式碼範例示範如何使用 Set 方法。
// Using method Set.
// Define the SHA1 encrypted password.
string newPassword =
"5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8";
// Define the user name.
string currentUserName = "userName";
// Create the new user.
FormsAuthenticationUser theUser =
new FormsAuthenticationUser(currentUserName, newPassword);
formsAuthenticationCredentials.Users.Set(theUser);
if (!authenticationSection.SectionInformation.IsLocked)
{
configuration.Save();
}
' Using method Set.
' Define the SHA1 encrypted password.
Dim newPassword As String = _
"5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8"
' Define the user name.
Dim currentUserName As String = "userName"
' Create the new user.
Dim theUser _
As New FormsAuthenticationUser(currentUserName, newPassword)
formsAuthenticationCredentials.Users.Set(theUser)
If Not authenticationSection.SectionInformation.IsLocked Then
configuration.Save()
End If