UserNamePasswordValidator.Validate(String, String) UserNamePasswordValidator.Validate(String, String) UserNamePasswordValidator.Validate(String, String) UserNamePasswordValidator.Validate(String, String) Method

Definición

Cuando se reemplaza en una clase derivada, valida el nombre de usuario y la contraseña especificadosWhen overridden in a derived class, validates the specified username and password.

public:
 abstract void Validate(System::String ^ userName, System::String ^ password);
public abstract void Validate (string userName, string password);
abstract member Validate : string * string -> unit
Public MustOverride Sub Validate (userName As String, password As String)

Parámetros

userName
String String String String

Nombre de usuario que se va a validar.The username to validate.

password
String String String String

La contraseña para validar.The password to validate.

Ejemplos

// 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");
    }
}
' 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

Comentarios

Invalide el método Validate para especificar cómo se validan el nombre de usuario y la contraseña.Override the Validate method to specify how the username and password is validated. Si el nombre de usuario y contraseña no pasan la validación, inicie SecurityTokenValidationException.If the username and password do not pass validation, then throw a SecurityTokenValidationException.

Se aplica a