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