AuthenticatingEventArgs.CustomCredential 속성

정의

인증을 위한 추가 사용자 값을 가져옵니다.

public:
 property System::String ^ CustomCredential { System::String ^ get(); };
public string CustomCredential { get; }
member this.CustomCredential : string
Public ReadOnly Property CustomCredential As String

속성 값

사용자 이름과 암호가 아닌 인증에 필요한 값입니다.

예제

다음 예제에서는 이벤트 처리기를 Authenticating 에서 두 개의 인증 값을 구문 분석 하는 이벤트를 CustomCredential 속성입니다. 이라는 사용자 지정 인증 클래스에 두 값 및 사용자 이름과 암호를 전달 하기 StudentAuthentication합니다.

void AuthenticationService_Authenticating(object sender, System.Web.ApplicationServices.AuthenticatingEventArgs e)
{
    string studentid = String.Empty;
    string answer = String.Empty;

    string[] credentials =
        e.CustomCredential.Split(new char[] { ',' });
    if (credentials.Length > 0)
    {
        studentid = credentials[0];
        if (credentials.Length > 1)
        {
            answer = credentials[1];
        }
    }

    try
    {
        e.Authenticated =
            StudentAuthentication.ValidateStudentCredentials
            (e.UserName, e.Password, studentid, answer);
    }
    catch (ArgumentNullException ex)
    {
        e.Authenticated = false;
    }

    e.AuthenticationIsComplete = true;
}
Sub AuthenticationService_Authenticating _
   (ByVal sender As Object, _
    ByVal e As System.Web.ApplicationServices.AuthenticatingEventArgs)
    Dim studentid As String = String.Empty
    Dim answer As String = String.Empty

    Dim credentials As String() = _
         e.CustomCredential.Split(New Char() {","c})
    If (credentials.Length > 0) Then
        studentid = credentials(0)
        If (credentials.Length > 1) Then
            answer = credentials(1)
        End If
    End If

    Try
        e.Authenticated = _
            StudentAuthentication.ValidateStudentCredentials _
            (e.Username, e.Password, studentid, answer)
    Catch ex As ArgumentNullException
        e.Authenticated = False
    End Try
    

    e.AuthenticationIsComplete = True
End Sub

설명

사용할 수는 CustomCredential 사용자 이름 및 암호 중이 아닌 인증 값을 검색할 속성의 Authenticating 이벤트입니다. 예를 들어, 사용자 이름 및 암호와 함께 id 번호의 유효성을 검사 하는 애플리케이션을 구성할 수 있습니다. id 번호는 전달 하는 경우는 CustomCredential 의 매개 변수는 Login 메서드. 통해 사용자 지정 값을 검색할 수 있습니다는 CustomCredential 속성입니다.

합니다 CustomCredential 속성에 전달 되어 동일한 형식으로 사용자 지정 된 값이 포함 된 Login 메서드. 에 Authenticating 둘 이상의 값 속성에 저장 되는 경우 이벤트 처리기의 값을 구문 분석 해야는 CustomCredential 속성 값을 검색 합니다.

적용 대상

추가 정보