IClientFormsAuthenticationCredentialsProvider.GetCredentials Method

Definition

Retrieves user credentials.

public:
 System::Web::ClientServices::Providers::ClientFormsAuthenticationCredentials ^ GetCredentials();
public System.Web.ClientServices.Providers.ClientFormsAuthenticationCredentials GetCredentials ();
abstract member GetCredentials : unit -> System.Web.ClientServices.Providers.ClientFormsAuthenticationCredentials
Public Function GetCredentials () As ClientFormsAuthenticationCredentials

Returns

The user login information.

Examples

The following example code demonstrates how to implement the GetCredentials method. In this example, the GetCredentials method is part of a login dialog box class. This method displays the dialog box, and then returns a ClientFormsAuthenticationCredentials instance initialized with the user-specified values.

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

Remarks

When using forms authentication with client application services, you can pass a user name and password to the ValidateUser method. You can also pass empty strings or null as the parameters to use a credentials provider. A credentials provider is a class that you provide and specify in your application configuration. A credentials provider class must implement the IClientFormsAuthenticationCredentialsProvider interface, which has a single method called GetCredentials. A typical GetCredentials method implementation will display a dialog box to retrieve user input. Using a credentials provider enables you to share a single login dialog box among multiple applications.

Applies to

See also