ClientWindowsAuthenticationMembershipProvider.ValidateUser Méthode

Définition

Authentifie automatiquement l’utilisateur actuel à l’aide de 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

A toujours la valeur true.

Exceptions

username n’est pas Empty ou null.

-ou-

password n’est pas Empty ou null.

Exemples

L’exemple de code suivant montre comment utiliser cette méthode pour authentifier un utilisateur à l’aide de l’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 fichier actif WindowsIdentity. Si une ClientRoleProvider application est configurée, vous pouvez utiliser l’objet ClientRolePrincipal pour récupérer les informations de rôle utilisateur du service de rôles.

S’applique à

Voir aussi