UserNamePasswordValidator 클래스

정의

사용자 이름과 암호의 유효성을 검사합니다.

public ref class UserNamePasswordValidator abstract
public abstract class UserNamePasswordValidator
type UserNamePasswordValidator = class
Public MustInherit Class UserNamePasswordValidator
상속
UserNamePasswordValidator

예제

public class MyCustomUserNameValidator : UserNamePasswordValidator
{
    // This method validates users. It allows two users, test1 and test2
    // with passwords 1tset and 2tset respectively.
    // This code is for illustration purposes only and
    // MUST NOT be used in a production environment because it is NOT secure.	
    public override void Validate(string userName, string password)
    {
        if (null == userName || null == password)
        {
            throw new ArgumentNullException();
        }

        if (!(userName == "test1" && password == "1tset") && !(userName == "test2" && password == "2tset"))
        {
            throw new SecurityTokenException("Unknown Username or Password");
        }
    }
}
Public Class MyCustomUserNameValidator
    Inherits UserNamePasswordValidator

    ' This method validates users. It allows two users, test1 and test2 
    ' with passwords 1tset and 2tset respectively.
    ' This code is for illustration purposes only and 
    ' MUST NOT be used in a production environment because it is NOT secure.	
    Public Overrides Sub Validate(ByVal userName As String, ByVal password As String)
        If Nothing = userName OrElse Nothing = password Then
            Throw New ArgumentNullException()
        End If

        If Not (userName = "test1" AndAlso password = "1tset") AndAlso Not (userName = "test2" AndAlso password = "2tset") Then
            Throw New SecurityTokenException("Unknown Username or Password")
        End If

    End Sub
End Class

설명

사용자 이름과 암호의 유효성을 검사하는 방법을 지정하려면 UserNamePasswordValidator 클래스를 사용합니다. UserNamePasswordValidator에서 클래스를 파생시키고 Validate 메서드를 재정의하여 이 작업을 수행할 수 있습니다. 사용자 지정 사용자 이름 및 암호 유효성 검사기를 만드는 방법에 대 한 자세한 내용은 참조 하세요. 방법: 사용자 지정 사용자 이름 및 암호 유효성 검사기를 사용 하 여입니다.

생성자

UserNamePasswordValidator()

UserNamePasswordValidator 클래스의 새 인스턴스를 초기화합니다.

속성

None

사용자 이름과 암호의 유효성을 검사하지 않는 유효성 검사기를 가져옵니다. 따라서 사용자 이름과 암호는 항상 유효한 것으로 간주됩니다.

메서드

CreateMembershipProviderValidator(MembershipProvider)

지정된 멤버 자격 공급자를 사용하여 사용자 이름과 암호의 유효성을 검사하는 UserNamePasswordValidator의 인스턴스를 가져옵니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)
Validate(String, String)

파생 클래스에서 재정의되는 경우 지정된 사용자 이름과 암호의 유효성을 검사합니다.

적용 대상