Sql Provider Membership
Sql Provider Membership
Sql Provider Membership
Manages storage of membership information for an ASP.NET application in a SQL Server database.
public ref class SqlMembershipProvider : System::Web::Security::MembershipProvider
public class SqlMembershipProvider : System.Web.Security.MembershipProvider
type SqlMembershipProvider = class inherit MembershipProvider
Public Class SqlMembershipProvider Inherits MembershipProvider
The following code example shows the Web.config file for an ASP.NET application configured to use a SqlMembershipProvider.
<configuration> <connectionStrings> <add name="SqlServices" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=aspnetdb;" /> </connectionStrings> <system.web> <authentication mode="Forms" > <forms loginUrl="login.aspx" name=".ASPXFORMSAUTH" /> </authentication> <authorization> <deny users="?" /> </authorization> <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15"> <providers> <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="SqlServices" applicationName="MyApplication" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" /> </providers> </membership> </system.web> </configuration>
This class is used by the Membership and MembershipUser classes to provide membership services for an ASP.NET application using a SQL Server database. You cannot use a SqlMembershipProvider without SQL Server. When your computer has SQL Server Express installed with the default instance name and user-instancing enabled, the SqlMembershipProvider object will create a database called
aspnetdb in the application's
App_Data directory the first time the application is run.
To manually create the database, run the
Aspnet_regsql.exe executable found in the
%systemroot%\Microsoft.NET\Framework\ versionNumber folder and specify the
-A m option (for example
aspnet_regsql.exe -A m). The database created is called Aspnetdb. Alternatively, run
Aspnet_regsql.exe to pull up the GUI configuration mode and choose to configure all ASP.NET Features.
If the membership provider is configured with a connection string that uses integrated security, the process account of the ASP.NET application must have rights to connect to the SQL Server database.
The Machine.config file defines a default SqlMembershipProvider instance named
AspNetSqlMembershipProvider that connects to the default SQL Server Express instance on the local machine. You can use this instance of the provider if you installed SQL Server Express with the default instance name, or you can define your own instance in the Web.config file for your ASP.NET application.
If you set the
passwordCompatMode attribute to Framework40, the application can use the hashing and encryption membership options that were added in ASP.NET 4. However, if the
passwordCompatMode attribute is set to Framework20, only the hashing and encryption membership options from the ASP.NET 2.0, ASP.NET 3.5, and ASP.NET 3.5 SP1 can be used. The default value is Framework20. For more information, see MembershipPasswordCompatibilityMode.
|SqlMembershipProvider() SqlMembershipProvider() SqlMembershipProvider() SqlMembershipProvider()||
Initializes a new instance of the SqlMembershipProvider class.
|ApplicationName ApplicationName ApplicationName ApplicationName||
Gets or sets the name of the application to store and retrieve membership information for.
|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||
Gets a value indicating whether the SQL Server membership provider is configured to allow users to reset their passwords.
|EnablePasswordRetrieval EnablePasswordRetrieval EnablePasswordRetrieval EnablePasswordRetrieval||
Gets a value indicating whether the SQL Server membership provider is configured to allow users to retrieve their passwords.
|MaxInvalidPasswordAttempts MaxInvalidPasswordAttempts MaxInvalidPasswordAttempts MaxInvalidPasswordAttempts||
Gets the number of invalid password or password-answer attempts allowed before the membership user is locked out.
|MinRequiredNonAlphanumericCharacters MinRequiredNonAlphanumericCharacters MinRequiredNonAlphanumericCharacters MinRequiredNonAlphanumericCharacters||
Gets the minimum number of special characters that must be present in a valid password.
|MinRequiredPasswordLength MinRequiredPasswordLength MinRequiredPasswordLength MinRequiredPasswordLength||
Gets the minimum length required for a password.
|Name Name Name Name||
Gets the friendly name used to refer to the provider during configuration.(Inherited from ProviderBase)
|PasswordAttemptWindow PasswordAttemptWindow PasswordAttemptWindow PasswordAttemptWindow||
Gets the time window between which consecutive failed attempts to provide a valid password or password answers are tracked.
|PasswordFormat PasswordFormat PasswordFormat PasswordFormat||
Gets a value indicating the format for storing passwords in the SQL Server membership database.
|PasswordStrengthRegularExpression PasswordStrengthRegularExpression PasswordStrengthRegularExpression PasswordStrengthRegularExpression||
Gets the regular expression used to evaluate a password.
|RequiresQuestionAndAnswer RequiresQuestionAndAnswer RequiresQuestionAndAnswer RequiresQuestionAndAnswer||
Gets a value indicating whether the SQL Server membership provider is configured to require the user to answer a password question for password reset and retrieval.
|RequiresUniqueEmail RequiresUniqueEmail RequiresUniqueEmail RequiresUniqueEmail||
Gets a value indicating whether the SQL Server membership provider is configured to require a unique email address for each user name.
|ValidatingPassword ValidatingPassword ValidatingPassword ValidatingPassword||
Occurs when a user is created, a password is changed, or a password is reset.(Inherited from MembershipProvider)