FormsAuthenticationUserCollection.Add(FormsAuthenticationUser) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Fügt der Auflistung ein FormsAuthenticationUser-Objekt hinzu.
public:
void Add(System::Web::Configuration::FormsAuthenticationUser ^ user);
public void Add (System.Web.Configuration.FormsAuthenticationUser user);
member this.Add : System.Web.Configuration.FormsAuthenticationUser -> unit
Public Sub Add (user As FormsAuthenticationUser)
Parameter
Das FormsAuthenticationUser-Objekt, das zur Auflistung hinzugefügt werden soll.
Ausnahmen
Das FormsAuthenticationUser-Objekt ist in der Auflistung bereits vorhanden, oder die Auflistung ist schreibgeschützt.
Beispiele
Im folgenden Codebeispiel wird die Verwendung der Add-Methode veranschaulicht.
// Using method Add.
// Define the SHA1 encrypted password.
// This example uses the SHA1 algorithm.
// Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
string password =
"5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8";
// Define the user name.
string userName = "newUser";
// Create the new user.
FormsAuthenticationUser currentUser =
new FormsAuthenticationUser(userName, password);
// Execute the Add method.
formsAuthenticationCredentials.Users.Add(currentUser);
// Update if not locked
if (!authenticationSection.SectionInformation.IsLocked)
{
configuration.Save();
}
' Using method Add.
' Define the SHA1 encrypted password.
' This example uses the SHA1 algorithm.
' Due to collision problems with SHA1, Microsoft recommends SHA256 or better.
Dim password As String = _
"5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8"
' Define the user name.
Dim userName As String = "newUser"
' Create the new user.
Dim currentUser _
As New FormsAuthenticationUser(userName, password)
' Execute the Add method.
formsAuthenticationCredentials.Users.Add(currentUser)
' Update if not locked
If Not authenticationSection.SectionInformation.IsLocked Then
configuration.Save()
End If
Hinweise
Die Auflistung darf kein Objekt mit demselben Namen enthalten FormsAuthenticationUser .