ClientWindowsAuthenticationMembershipProvider.ValidateUser Méthode

Définition

Authentifie automatiquement l'utilisateur actuel en utilisant l'identité fournie par le système d'exploitation.

public:
 override bool ValidateUser(System::String ^ username, System::String ^ password);
public override bool ValidateUser (string username, string password);
override this.ValidateUser : string * string -> bool
Public Overrides Function ValidateUser (username As String, password As String) As Boolean

Paramètres

username
String

Doit être Empty ou null.

password
String

Doit être Empty ou null.

Retours

Toujours true.

Exceptions

username n'est pas Empty, ni null.

- ou -

password n'est pas Empty, ni null.

Exemples

L’exemple de code suivant montre comment utiliser cette méthode pour authentifier un utilisateur à l’aide de Authentification Windows.

private bool ValidateUsingWindowsAuthentication()
{
    ClientWindowsAuthenticationMembershipProvider authProvider =
        System.Web.Security.Membership.Provider as
        ClientWindowsAuthenticationMembershipProvider;

    // Call ValidateUser and pass null values for the parameters.
    // This call always returns true.
    return authProvider.ValidateUser(null, null);
}
Private Function ValidateUsingWindowsAuthentication() As Boolean

    Dim authProvider As ClientWindowsAuthenticationMembershipProvider = _
        CType(System.Web.Security.Membership.Provider,  _
        ClientWindowsAuthenticationMembershipProvider)

    ' Call ValidateUser and pass Nothing for the parameters.
    ' This call always returns true.
    Return authProvider.ValidateUser(Nothing, Nothing)

End Function

Remarques

Lorsque vous configurez votre application pour utiliser la ClientWindowsAuthenticationMembershipProvider classe , la staticMembership.ValidateUser méthode utilise cette méthode pour son implémentation. La ClientWindowsAuthenticationMembershipProvider.ValidateUser méthode authentifie automatiquement l’utilisateur actuel et définit la staticThread.CurrentPrincipal propriété sur un ClientRolePrincipal objet qui contient le actuel WindowsIdentity. Si un ClientRoleProvider est configuré pour votre application, vous pouvez utiliser l’objet pour récupérer des ClientRolePrincipal informations de rôle utilisateur à partir du service de rôles.

S’applique à

Voir aussi