ClientFormsAuthenticationMembershipProvider Class

ClientFormsAuthenticationMembershipProvider Class

 

Enables forms authentication with client application services.

Namespace:   System.Web.ClientServices.Providers
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

System.Object
  System.Configuration.Provider.ProviderBase
    System.Web.Security.MembershipProvider
      System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider

public class ClientFormsAuthenticationMembershipProvider : MembershipProvider

NameDescription
System_CAPS_pubmethodClientFormsAuthenticationMembershipProvider()

Initializes a new instance of the ClientFormsAuthenticationMembershipProvider class.

NameDescription
System_CAPS_pubpropertyApplicationName

This property is not used by this class.(Overrides MembershipProvider.ApplicationName.)

System_CAPS_pubpropertyDescription

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

System_CAPS_pubpropertyEnablePasswordReset

This property is not used by this class.(Overrides MembershipProvider.EnablePasswordReset.)

System_CAPS_pubpropertyEnablePasswordRetrieval

This property is not used by this class.(Overrides MembershipProvider.EnablePasswordRetrieval.)

System_CAPS_pubpropertyMaxInvalidPasswordAttempts

This property is not used by this class.(Overrides MembershipProvider.MaxInvalidPasswordAttempts.)

System_CAPS_pubpropertyMinRequiredNonAlphanumericCharacters

This property is not used by this class.(Overrides MembershipProvider.MinRequiredNonAlphanumericCharacters.)

System_CAPS_pubpropertyMinRequiredPasswordLength

This property is not used by this class.(Overrides MembershipProvider.MinRequiredPasswordLength.)

System_CAPS_pubpropertyName

Gets the friendly name used to refer to the provider during configuration.(Inherited from ProviderBase.)

System_CAPS_pubpropertyPasswordAttemptWindow

This property is not used by this class.(Overrides MembershipProvider.PasswordAttemptWindow.)

System_CAPS_pubpropertyPasswordFormat

This property is not used by this class.(Overrides MembershipProvider.PasswordFormat.)

System_CAPS_pubpropertyPasswordStrengthRegularExpression

This property is not used by this class.(Overrides MembershipProvider.PasswordStrengthRegularExpression.)

System_CAPS_pubpropertyRequiresQuestionAndAnswer

This property is not used by this class.(Overrides MembershipProvider.RequiresQuestionAndAnswer.)

System_CAPS_pubpropertyRequiresUniqueEmail

This property is not used by this class.(Overrides MembershipProvider.RequiresUniqueEmail.)

System_CAPS_pubpropertyServiceUri

Gets or sets the URI of the authentication service.

NameDescription
System_CAPS_pubmethodChangePassword(String, String, String)

This method is not used by this class.(Overrides MembershipProvider.ChangePassword(String, String, String).)

System_CAPS_pubmethodChangePasswordQuestionAndAnswer(String, String, String, String)
System_CAPS_pubmethodCreateUser(String, String, String, String, String, Boolean, Object, MembershipCreateStatus)
System_CAPS_protmethodDecryptPassword(Byte[])

Decrypts an encrypted password.(Inherited from MembershipProvider.)

System_CAPS_pubmethodDeleteUser(String, Boolean)

This method is not used by this class.(Overrides MembershipProvider.DeleteUser(String, Boolean).)

System_CAPS_protmethodEncryptPassword(Byte[])

Encrypts a password.(Inherited from MembershipProvider.)

System_CAPS_protmethodEncryptPassword(Byte[], MembershipPasswordCompatibilityMode)

Encrypts the specified password using the specified password-compatibility mode.(Inherited from MembershipProvider.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodFindUsersByEmail(String, Int32, Int32, Int32)

This method is not used by this class.(Overrides MembershipProvider.FindUsersByEmail(String, Int32, Int32, Int32).)

System_CAPS_pubmethodFindUsersByName(String, Int32, Int32, Int32)

This method is not used by this class.(Overrides MembershipProvider.FindUsersByName(String, Int32, Int32, Int32).)

System_CAPS_pubmethodGetAllUsers(Int32, Int32, Int32)

This method is not used by this class.(Overrides MembershipProvider.GetAllUsers(Int32, Int32, Int32).)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetNumberOfUsersOnline()

This method is not used by this class.(Overrides MembershipProvider.GetNumberOfUsersOnline().)

System_CAPS_pubmethodGetPassword(String, String)

This method is not used by this class.(Overrides MembershipProvider.GetPassword(String, String).)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodGetUser(Object, Boolean)

This method is not used by this class.(Overrides MembershipProvider.GetUser(Object, Boolean).)

System_CAPS_pubmethodGetUser(String, Boolean)

This method is not used by this class.(Overrides MembershipProvider.GetUser(String, Boolean).)

System_CAPS_pubmethodGetUserNameByEmail(String)

This method is not used by this class.(Overrides MembershipProvider.GetUserNameByEmail(String).)

System_CAPS_pubmethodInitialize(String, NameValueCollection)

Initializes the provider.(Overrides ProviderBase.Initialize(String, NameValueCollection).)

System_CAPS_pubmethodLogout()

Logs out the user.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodOnValidatingPassword(ValidatePasswordEventArgs)

Raises the ValidatingPassword event if an event handler has been defined.(Inherited from MembershipProvider.)

System_CAPS_pubmethodResetPassword(String, String)

This method is not used by this class.(Overrides MembershipProvider.ResetPassword(String, String).)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodUnlockUser(String)

This method is not used by this class.(Overrides MembershipProvider.UnlockUser(String).)

System_CAPS_pubmethodUpdateUser(MembershipUser)

This method is not used by this class.(Overrides MembershipProvider.UpdateUser(MembershipUser).)

System_CAPS_pubmethodValidateUser(String, String)

Authenticates a user by using the specified user name and password.(Overrides MembershipProvider.ValidateUser(String, String).)

System_CAPS_pubmethodValidateUser(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.

System_CAPS_pubmethodSystem_CAPS_staticValidateUser(String, String, String)

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

NameDescription
System_CAPS_pubeventUserValidated

Occurs when the user is validated.

System_CAPS_pubeventValidatingPassword

Occurs when a user is created, a password is changed, or a password is reset.(Inherited from MembershipProvider.)

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.

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;
}

.NET Framework
Available since 3.5

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft