ClientWindowsAuthenticationMembershipProvider
Class
Definition
Enables Windows authentication with client application services.
public class ClientWindowsAuthenticationMembershipProvider : System.Web.Security.MembershipProvider
- Inheritance
Inherited Members
System.Configuration.Provider.ProviderBase
System.Object
System.Web.Security.MembershipProvider
Examples
The following example code demonstrates how to use this method to authenticate a user by using Windows authentication. In this example, the value of the static Membership.Provider property is cast to a ClientWindowsAuthenticationMembershipProvider instance. This makes sure that a NullReferenceException will be thrown if you accidentally test this code by using another membership provider.
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
Remarks
You can use client application services to validate users by using Windows authentication. To enable Windows authentication, you configure your application to use the ClientWindowsAuthenticationMembershipProvider class. For more information, see How to: Configure Client Application Services.
After configuration, you can validate users by calling the static Membership.ValidateUser method. The Membership.ValidateUser method internally calls the ValidateUser method.
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. 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 ClientWindowsAuthenticationMembershipProvider instance through the static Membership.Provider property. You can use the membership provider reference to call the ClientWindowsAuthenticationMembershipProvider.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.
Constructors
| ClientWindowsAuthenticationMembershipProvider() |
Initializes a new instance of the ClientWindowsAuthenticationMembershipProvider class. |
Properties
| ApplicationName |
This property is not used by this class. |
| EnablePasswordReset |
This property is not used by this class. |
| EnablePasswordRetrieval |
This property is not used by this class. |
| MaxInvalidPasswordAttempts |
This property is not used by this class. |
| MinRequiredNonAlphanumericCharacters |
This property is not used by this class. |
| MinRequiredPasswordLength |
This property is not used by this class. |
| PasswordAttemptWindow |
This property is not used by this class. |
| PasswordFormat |
This property is not used by this class. |
| PasswordStrengthRegularExpression |
This property is not used by this class. |
| RequiresQuestionAndAnswer |
This property is not used by this class. |
| RequiresUniqueEmail |
This property is not used by this class. |
Methods
| ChangePassword(String, String, String) |
This method is not used by this class. |
| ChangePasswordQuestionAndAnswer(String, String, String, String) |
This method is not used by this class. |
| CreateUser(String, String, String, String, String, Boolean, Object, MembershipCreateStatus) |
This method is not used by this class. |
| DeleteUser(String, Boolean) |
This method is not used by this class. |
| FindUsersByEmail(String, Int32, Int32, Int32) |
This method is not used by this class. |
| FindUsersByName(String, Int32, Int32, Int32) |
This method is not used by this class. |
| GetAllUsers(Int32, Int32, Int32) |
This method is not used by this class. |
| GetNumberOfUsersOnline() |
This method is not used by this class. |
| GetPassword(String, String) |
This method is not used by this class. |
| GetUser(String, Boolean) |
This method is not used by this class. |
| GetUser(Object, Boolean) |
This method is not used by this class. |
| GetUserNameByEmail(String) |
This method is not used by this class. |
| Logout() |
Logs out the user. |
| ResetPassword(String, String) |
This method is not used by this class. |
| UnlockUser(String) |
This method is not used by this class. |
| UpdateUser(MembershipUser) |
This method is not used by this class. |
| ValidateUser(String, String) |
Automatically authenticates the current user by using the identity supplied by the operating system. |