다음을 통해 공유


FormsAuthenticationUserCollection.Add(FormsAuthenticationUser) 메서드

정의

컬렉션에 FormsAuthenticationUser 개체를 추가합니다.

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)

매개 변수

user
FormsAuthenticationUser

컬렉션에 추가할 FormsAuthenticationUser 개체입니다.

예외

FormsAuthenticationUser 개체가 컬렉션에 이미 있거나 컬렉션이 읽기 전용인 경우

예제

다음 코드 예제에서는 Add 메서드를 사용하는 방법을 보여 줍니다.

// 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

설명

컬렉션에 포함 되지 해야는 FormsAuthenticationUser 동일한 이름 가진 개체입니다.

적용 대상