ClientWindowsAuthenticationMembershipProvider.ValidateUser(String, String) Método

Definição

Autentica automaticamente o usuário atual usando a identidade fornecida pelo sistema operacional.Automatically authenticates the current user by using the identity supplied by the operating system.

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

Parâmetros

username
String

Deve ser Empty ou null.Must be Empty or null.

password
String

Deve ser Empty ou null.Must be Empty or null.

Retornos

Boolean

Sempre true.Always true.

Exceções

username não é Empty ou null.username is not Empty or null.

- ou --or- password não é Empty ou null.password is not Empty or null.

Exemplos

O código de exemplo a seguir demonstra como usar esse método para autenticar um usuário usando a autenticação do Windows.The following example code demonstrates how to use this method to authenticate a user by using Windows authentication.

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

Comentários

Quando você configura seu aplicativo para usar a ClientWindowsAuthenticationMembershipProvider classe, o static Membership.ValidateUser método usará esse método para sua implementação.When you configure your application to use the ClientWindowsAuthenticationMembershipProvider class, the static Membership.ValidateUser method will use this method for its implementation. O ClientWindowsAuthenticationMembershipProvider.ValidateUser método autentica automaticamente o usuário atual e define a static Thread.CurrentPrincipal propriedade para um ClientRolePrincipal objeto que contém o atual WindowsIdentity .The ClientWindowsAuthenticationMembershipProvider.ValidateUser method automatically authenticates the current user and sets the static Thread.CurrentPrincipal property to a ClientRolePrincipal object that contains the current WindowsIdentity. Se um ClientRoleProvider estiver configurado para seu aplicativo, você poderá usar o ClientRolePrincipal objeto para recuperar informações de função de usuário do serviço de funções.If a ClientRoleProvider is configured for your application, you can use the ClientRolePrincipal object to retrieve user role information from the roles service.

Aplica-se a

Confira também