Validates user credentials and manages user settings. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
Gets or sets the name of the application.
Gets a value indicating whether the current membership provider is configured to allow users to reset their passwords.
Gets a value indicating whether the current membership provider is configured to allow users to retrieve their passwords.
The identifier of the algorithm used to hash passwords.
Gets the number of invalid password or password-answer attempts allowed before the membership user is locked out.
Gets the minimum number of special characters that must be present in a valid password.
Gets the minimum length required for a password.
Gets the time window between which consecutive failed attempts to provide a valid password or password answer are tracked.
Gets the regular expression used to evaluate a password.
Gets a reference to the default membership provider for the application.
Gets a collection of the membership providers for the ASP.NET application.
Gets a value indicating whether the default membership provider requires the user to answer a password question for password reset and retrieval.
Specifies the number of minutes after the last-activity date/time stamp for a user during which the user is considered online.
Adds a new user to the data store.
|CreateUser(String, String, String)|
Adds a new user with a specified e-mail address to the data store.
|CreateUser(String, String, String, String, String, Boolean, MembershipCreateStatus)|
Adds a new user with specified property values to the data store and returns a status parameter indicating that the user was successfully created or the reason the user creation failed.
|CreateUser(String, String, String, String, String, Boolean, Object, MembershipCreateStatus)|
Adds a new user with specified property values and a unique identifier to the data store and returns a status parameter indicating that the user was successfully created or the reason the user creation failed.
Deletes a user and any related user data from the database.
Deletes a user from the database.
Gets a collection of membership users where the e-mail address contains the specified e-mail address to match.
|FindUsersByEmail(String, Int32, Int32, Int32)|
Gets a collection of membership users, in a page of data, where the e-mail address contains the specified e-mail address to match.
Gets a collection of membership users where the user name contains the specified user name to match.
|FindUsersByName(String, Int32, Int32, Int32)|
Gets a collection of membership users, in a page of data, where the user name contains the specified user name to match.
Generates a random password of the specified length.
Gets a collection of all the users in the database.
|GetAllUsers(Int32, Int32, Int32)|
Gets a collection of all the users in the database in pages of data.
Gets the number of users currently accessing an application.
Gets the information from the data source and updates the last-activity date/time stamp for the current logged-on membership user.
Gets the information from the data source for the current logged-on membership user. Updates the last-activity date/time stamp for the current logged-on membership user, if specified.
Gets the information from the data source for the membership user associated with the specified unique identifier.
Gets the information from the data source for the membership user associated with the specified unique identifier. Updates the last-activity date/time stamp for the user, if specified.
Gets the information from the data source for the specified membership user.
Gets the information from the data source for the specified membership user. Updates the last-activity date/time stamp for the user, if specified.
Gets a user name where the e-mail address for the user matches the specified e-mail address.
Updates the database with the information for the specified user.
Verifies that the supplied user name and password are valid.
Occurs when a user is created, a password is changed, or a password is reset.
The FormsAuthentication to create a complete system for authenticating users of a Web application or site. The Login control encapsulates the class to provide a convenient mechanism for validating users.class is used in ASP.NET applications to validate user credentials and manage user settings such as passwords and e-mail addresses. The class can be used on its own, or in conjunction with the
If you are not familiar with the membership features of ASP.NET, see Introduction to Membership before continuing. For a list of other topics related to membership, see Managing Users by Using Membership.
Theclass provides facilities for:
Creating new users.
Storing membership information (user names, passwords, e-mail addresses, and supporting data) in Microsoft SQL Server or in an alternative data store.
Authenticating users who visit your site. You can authenticate users programmatically, or you can use the Login control to create a complete authentication system that requires little or no code.
Managing passwords, which includes creating, changing, retrieving, and resetting them, and so on. You can optionally configure ASP.NET membership to require a password question and answer to authenticate password reset or retrieval requests for users that have forgotten their password.
Although ASP.NET membership is a self-standing feature in ASP.NET For authentication, it can be integrated with ASP.NET role management to provide authorization services for your site. Membership can also be integrated with the ASP.NET user System.Web.Profile to provide application-specific customization that can be tailored to individual users. For details, see Understanding Role Management and ASP.NET Profile Properties Overview.
The SqlMembershipProvider, which stores user information in a Microsoft SQL Server database, and an ActiveDirectoryMembershipProvider, which enables you to store user information on an Active Directory or Active Directory Application Mode (ADAM) server. You can also implement a custom membership provider to communicate with an alternative data source that can be used by the class. Custom membership providers inherit the MembershipProvider abstract class. For more information, see Implementing a Membership Provider.class relies on membership providers to communicate with a data source. The .NET Framework includes a
By default, ASP.NET membership is enabled for all ASP.NET applications. The default membership provider is the SqlMembershipProvider and is specified in the machine configuration with the name AspNetSqlProvider. The default instance of the SqlMembershipProvider is configured to connect to a local instance of Microsoft SQL Server.
You can modify the default settings to specify a SqlMembershipProvider other than the AspNetSqlProvider instance as the default provider, or specify an instance of a custom provider as the default provider for your ASP.NET application using the Web.config file. You can specify the ASP.NET membership configuration for your Web application using the configuration section in the Web.config file. You can use the providers subsection of the section to specify a membership provider other than one of the default providers. For example, the following section removes the default membership providers from the current application configuration and adds a new provider with a name of SqlProvider that connects to a SQL Server instance named AspSqlServer.
<configuration> <connectionStrings> <add name="SqlServices" connectionString="Data Source=AspSqlServer;Integrated Security=SSPI;Initial Catalog=aspnetdb;" /> </connectionStrings> <system.web> <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="20"> <providers> <remove name="AspNetSqlProvider" /> <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="SqlServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" passwordFormat="Hashed" applicationName="/" /> </providers> </membership> </system.web> </configuration>
The following code example shows the login page for an ASP.NET application configured to use forms authentication and ASP.NET membership. If the supplied user credentials are invalid, a message is displayed to the user. Otherwise, the user is redirected to the originally requested URL using the RedirectFromLoginPage method.
The ASP.NET login controls (Login, LoginView, LoginStatus, LoginName, and PasswordRecovery) encapsulate virtually all of the logic required to prompt users for credentials and validate the credentials in the membership system and can be used in place of programmatic checking using the class.
This example contains a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.
Available since 2.0
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.