ClientFormsAuthenticationMembershipProvider ClientFormsAuthenticationMembershipProvider ClientFormsAuthenticationMembershipProvider ClientFormsAuthenticationMembershipProvider Class

Definition

Enables forms authentication with client application services.

public ref class ClientFormsAuthenticationMembershipProvider : System::Web::Security::MembershipProvider
public class ClientFormsAuthenticationMembershipProvider : System.Web.Security.MembershipProvider
type ClientFormsAuthenticationMembershipProvider = class
    inherit MembershipProvider
Public Class ClientFormsAuthenticationMembershipProvider
Inherits MembershipProvider
Inheritance
ClientFormsAuthenticationMembershipProviderClientFormsAuthenticationMembershipProviderClientFormsAuthenticationMembershipProviderClientFormsAuthenticationMembershipProvider

Examples

The following example code demonstrates how to use this method to validate the user by using an IClientFormsAuthenticationCredentialsProvider implementation.

private bool ValidateUsingCredentialsProvider()
{
    bool isAuthorized = false;
    try
    {
        ClientFormsAuthenticationMembershipProvider authProvider =
            System.Web.Security.Membership.Provider as
            ClientFormsAuthenticationMembershipProvider;

        // Call ValidateUser with empty strings in order to display the 
        // login dialog box configured as a credentials provider.
        isAuthorized = authProvider.ValidateUser(String.Empty, String.Empty);
    }
    catch (System.Net.WebException)
    {
        MessageBox.Show("Unable to access the authentication service.",
            "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
    }
    if (!isAuthorized)
    {
        MessageBox.Show("Unable to authenticate.", "Not logged in", 
            MessageBoxButtons.OK, MessageBoxIcon.Error);
        Application.Exit();
    }
    return isAuthorized;
}
Private Function ValidateUsingCredentialsProvider() As Boolean

    Dim isAuthorized As Boolean = False

    Try

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

        ' Call ValidateUser with empty strings in order to display the 
        ' login dialog box configured as a credentials provider.
        isAuthorized = authProvider.ValidateUser(String.Empty, String.Empty)

    Catch ex As System.Net.WebException

        MessageBox.Show("Unable to access the authentication service.", _
            "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)

    End Try

    If Not isAuthorized Then

        MessageBox.Show("Unable to authenticate.", "Not logged in", _
            MessageBoxButtons.OK, MessageBoxIcon.Error)
        Application.Exit()

    End If

    Return isAuthorized

End Function

Remarks

You can use client application services to validate users by using forms authentication. To enable forms authentication, you configure your application to use the ClientFormsAuthenticationMembershipProvider class. For more information, see How to: Configure Client Application Services.

After configuration, you can validate users by calling the static Membership.ValidateUser method, which internally calls the ClientFormsAuthenticationMembershipProvider.ValidateUser(String, String) method.

Forms authentication requires that the user specify their credentials through login controls provided by your application. You can retrieve the credentials and pass them to the Membership.ValidateUser method. You can also pass in empty strings or null to use a credentials provider. A credentials provider is an IClientFormsAuthenticationCredentialsProvider implementation specified in your application configuration file. You will typically implement the IClientFormsAuthenticationCredentialsProvider.GetCredentials method to display a login dialog box and return a populated ClientFormsAuthenticationCredentials object. Using a credentials provider enables you to share a single login dialog box among multiple applications.

The ClientFormsAuthenticationMembershipProvider.ValidateUser method authenticates users through the login service indicated by the ServiceUri property. The value of the ServiceUri property is typically retrieved from the application configuration file along with other configuration values. For more information, see How to: Configure Client Application Services.

If the user is successfully authenticated, the service provider sets the static Thread.CurrentPrincipal property to a new ClientRolePrincipal object that contains a new ClientFormsIdentity object that contains the user information. If a ClientRoleProvider is configured for your application, you can use the ClientRolePrincipal object to retrieve user role information from the roles service.

You can retrieve a reference to the current ClientFormsAuthenticationMembershipProvider instance through the static Membership.Provider property. You can use the membership provider reference to call the ClientFormsAuthenticationMembershipProvider.ValidateUser method directly. Additionally, you will need the membership provider reference to call the Logout method, which is not available in the MembershipProvider base class.

You cannot use the ClientFormsAuthenticationMembershipProvider class to create, delete, or modify membership information. To create, delete, or modify users, you must change the configuration of the login service on the server.

Constructors

ClientFormsAuthenticationMembershipProvider() ClientFormsAuthenticationMembershipProvider() ClientFormsAuthenticationMembershipProvider() ClientFormsAuthenticationMembershipProvider()

Initializes a new instance of the ClientFormsAuthenticationMembershipProvider class.

Properties

ApplicationName ApplicationName ApplicationName ApplicationName

This property is not used by this class.

Description Description Description Description

Gets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs).

(Inherited from ProviderBase)
EnablePasswordReset EnablePasswordReset EnablePasswordReset EnablePasswordReset

This property is not used by this class.

EnablePasswordRetrieval EnablePasswordRetrieval EnablePasswordRetrieval EnablePasswordRetrieval

This property is not used by this class.

MaxInvalidPasswordAttempts MaxInvalidPasswordAttempts MaxInvalidPasswordAttempts MaxInvalidPasswordAttempts

This property is not used by this class.

MinRequiredNonAlphanumericCharacters MinRequiredNonAlphanumericCharacters MinRequiredNonAlphanumericCharacters MinRequiredNonAlphanumericCharacters

This property is not used by this class.

MinRequiredPasswordLength MinRequiredPasswordLength MinRequiredPasswordLength MinRequiredPasswordLength

This property is not used by this class.

Name Name Name Name

Gets the friendly name used to refer to the provider during configuration.

(Inherited from ProviderBase)
PasswordAttemptWindow PasswordAttemptWindow PasswordAttemptWindow PasswordAttemptWindow

This property is not used by this class.

PasswordFormat PasswordFormat PasswordFormat PasswordFormat

This property is not used by this class.

PasswordStrengthRegularExpression PasswordStrengthRegularExpression PasswordStrengthRegularExpression PasswordStrengthRegularExpression

This property is not used by this class.

RequiresQuestionAndAnswer RequiresQuestionAndAnswer RequiresQuestionAndAnswer RequiresQuestionAndAnswer

This property is not used by this class.

RequiresUniqueEmail RequiresUniqueEmail RequiresUniqueEmail RequiresUniqueEmail

This property is not used by this class.

ServiceUri ServiceUri ServiceUri ServiceUri

Gets or sets the URI of the authentication service.

Methods

ChangePassword(String, String, String) ChangePassword(String, String, String) ChangePassword(String, String, String) ChangePassword(String, String, String)

This method is not used by this class.

ChangePasswordQuestionAndAnswer(String, String, String, String) ChangePasswordQuestionAndAnswer(String, String, String, String) ChangePasswordQuestionAndAnswer(String, String, String, String) ChangePasswordQuestionAndAnswer(String, String, String, String)

This method is not used by this class.

CreateUser(String, String, String, String, String, Boolean, Object, MembershipCreateStatus) CreateUser(String, String, String, String, String, Boolean, Object, MembershipCreateStatus) CreateUser(String, String, String, String, String, Boolean, Object, MembershipCreateStatus) CreateUser(String, String, String, String, String, Boolean, Object, MembershipCreateStatus)

This method is not used by this class.

DecryptPassword(Byte[]) DecryptPassword(Byte[]) DecryptPassword(Byte[]) DecryptPassword(Byte[])

Decrypts an encrypted password.

(Inherited from MembershipProvider)
DeleteUser(String, Boolean) DeleteUser(String, Boolean) DeleteUser(String, Boolean) DeleteUser(String, Boolean)

This method is not used by this class.

EncryptPassword(Byte[]) EncryptPassword(Byte[]) EncryptPassword(Byte[]) EncryptPassword(Byte[])

Encrypts a password.

(Inherited from MembershipProvider)
EncryptPassword(Byte[], MembershipPasswordCompatibilityMode) EncryptPassword(Byte[], MembershipPasswordCompatibilityMode) EncryptPassword(Byte[], MembershipPasswordCompatibilityMode) EncryptPassword(Byte[], MembershipPasswordCompatibilityMode)

Encrypts the specified password using the specified password-compatibility mode.

(Inherited from MembershipProvider)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
FindUsersByEmail(String, Int32, Int32, Int32) FindUsersByEmail(String, Int32, Int32, Int32) FindUsersByEmail(String, Int32, Int32, Int32) FindUsersByEmail(String, Int32, Int32, Int32)

This method is not used by this class.

FindUsersByName(String, Int32, Int32, Int32) FindUsersByName(String, Int32, Int32, Int32) FindUsersByName(String, Int32, Int32, Int32) FindUsersByName(String, Int32, Int32, Int32)

This method is not used by this class.

GetAllUsers(Int32, Int32, Int32) GetAllUsers(Int32, Int32, Int32) GetAllUsers(Int32, Int32, Int32) GetAllUsers(Int32, Int32, Int32)

This method is not used by this class.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetNumberOfUsersOnline() GetNumberOfUsersOnline() GetNumberOfUsersOnline() GetNumberOfUsersOnline()

This method is not used by this class.

GetPassword(String, String) GetPassword(String, String) GetPassword(String, String) GetPassword(String, String)

This method is not used by this class.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
GetUser(Object, Boolean) GetUser(Object, Boolean) GetUser(Object, Boolean) GetUser(Object, Boolean)

This method is not used by this class.

GetUser(String, Boolean) GetUser(String, Boolean) GetUser(String, Boolean) GetUser(String, Boolean)

This method is not used by this class.

GetUserNameByEmail(String) GetUserNameByEmail(String) GetUserNameByEmail(String) GetUserNameByEmail(String)

This method is not used by this class.

Initialize(String, NameValueCollection) Initialize(String, NameValueCollection) Initialize(String, NameValueCollection) Initialize(String, NameValueCollection)

Initializes the provider.

Logout() Logout() Logout() Logout()

Logs out the user.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnValidatingPassword(ValidatePasswordEventArgs) OnValidatingPassword(ValidatePasswordEventArgs) OnValidatingPassword(ValidatePasswordEventArgs) OnValidatingPassword(ValidatePasswordEventArgs)

Raises the ValidatingPassword event if an event handler has been defined.

(Inherited from MembershipProvider)
ResetPassword(String, String) ResetPassword(String, String) ResetPassword(String, String) ResetPassword(String, String)

This method is not used by this class.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)
UnlockUser(String) UnlockUser(String) UnlockUser(String) UnlockUser(String)

This method is not used by this class.

UpdateUser(MembershipUser) UpdateUser(MembershipUser) UpdateUser(MembershipUser) UpdateUser(MembershipUser)

This method is not used by this class.

ValidateUser(String, String) ValidateUser(String, String) ValidateUser(String, String) ValidateUser(String, String)

Authenticates a user by using the specified user name and password.

ValidateUser(String, String, Boolean) ValidateUser(String, String, Boolean) ValidateUser(String, String, Boolean) ValidateUser(String, String, Boolean)

Authenticates a user by using the specified user name and password, optionally storing a hash of the password in the local data cache.

ValidateUser(String, String, String) ValidateUser(String, String, String) ValidateUser(String, String, String) ValidateUser(String, String, String)

Authenticates a user at the specified service URI by using the specified user name and password.

Events

UserValidated UserValidated UserValidated UserValidated

Occurs when the user is validated.

ValidatingPassword ValidatingPassword ValidatingPassword ValidatingPassword

Occurs when a user is created, a password is changed, or a password is reset.

(Inherited from MembershipProvider)

Applies to

See Also