UserNamePasswordValidator Classe

Definizione

Convalida un nome utente e una password.

public ref class UserNamePasswordValidator abstract
public abstract class UserNamePasswordValidator
type UserNamePasswordValidator = class
Public MustInherit Class UserNamePasswordValidator
Ereditarietà
UserNamePasswordValidator

Esempio

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

Commenti

Utilizzare la classe UserNamePasswordValidator per specificare la modalità di convalida di un nome utente e di una password. Questa operazione può essere eseguita derivando una classe dalla classe UserNamePasswordValidator ed eseguendo l'override del metodo Validate. Per altre informazioni sulla creazione di un validore di nome utente e password personalizzato, vedere Procedura: Usare un nome utente personalizzato e un validator password.

Costruttori

UserNamePasswordValidator()

Inizializza una nuova istanza della classe UserNamePasswordValidator.

Proprietà

None

Ottiene un validator che non esegue alcuna convalida del nome utente e della password. Di conseguenza, il nome utente e la password vengono sempre ritenuti validi.

Metodi

CreateMembershipProviderValidator(MembershipProvider)

Ottiene un'istanza di una classe UserNamePasswordValidator che convalida un nome utente e una password utilizzando il provider di appartenenze specificato.

Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)
Validate(String, String)

Quando viene sottoposta a override in una classe derivata, convalida il nome utente e la password specificati.

Si applica a