IClientFormsAuthenticationCredentialsProvider 接口

定义

定义类调用以检索用户凭据的方法 ClientFormsAuthenticationMembershipProvider

public interface class IClientFormsAuthenticationCredentialsProvider
public interface IClientFormsAuthenticationCredentialsProvider
type IClientFormsAuthenticationCredentialsProvider = interface
Public Interface IClientFormsAuthenticationCredentialsProvider

示例

以下示例代码演示如何实现 GetCredentials 该方法,该方法是此接口中唯一的成员。 在此示例中,该方法 GetCredentials 是登录对话框类的一部分。 此方法显示对话框,然后返回 ClientFormsAuthenticationCredentials 使用用户指定的值初始化的实例。

public ClientFormsAuthenticationCredentials GetCredentials()
{
    if (this.ShowDialog() == DialogResult.OK)
    {
        return new ClientFormsAuthenticationCredentials(
            usernameTextBox.Text, passwordTextBox.Text,
            rememberMeCheckBox.Checked);
    }
    else
    {
        return null;
    }
}
Public Function GetCredentials() As  _
    ClientFormsAuthenticationCredentials Implements _
    IClientFormsAuthenticationCredentialsProvider.GetCredentials

    If Me.ShowDialog() = DialogResult.OK Then
        Return New ClientFormsAuthenticationCredentials( _
            UsernameTextBox.Text, PasswordTextBox.Text, _
            rememberMeCheckBox.Checked)
    Else
        Return Nothing
    End If

End Function

注解

在客户端应用程序服务中使用表单身份验证时,可以将用户名和密码传递给 ValidateUser 该方法。 还可以传递空字符串或 null 作为参数来使用凭据提供程序。 凭据提供程序是在应用程序配置中提供的和指定的类。 凭据提供程序类必须实现 IClientFormsAuthenticationCredentialsProvider 接口,该接口具有一个名为 GetCredentials 的方法。 典型的 GetCredentials 方法实现将显示用于检索用户输入的对话框。 使用凭据提供程序可以在多个应用程序之间共享单个登录对话框。

方法

名称 说明
GetCredentials()

检索用户凭据。

适用于

另请参阅