asp.net.ph

SqlMembershipProvider Class

System.Web.Security Namespace


.NET Framework version 2.0

Manages storage of membership information for an ASP.NET application in a SQL Server database.

SqlMembershipProvider Class Members

Collapse   Constructors

Visibility Constructor Parameters
public SqlMembershipProvider ( )

Collapse   Properties

Visibility Name Value Type Accessibility
public ApplicationName String [ Get , Set ]
public EnablePasswordReset Boolean [ Get ]
public EnablePasswordRetrieval Boolean [ Get ]
public MaxInvalidPasswordAttempts Int32 [ Get ]
public MinRequiredNonAlphanumericCharacters Int32 [ Get ]
public MinRequiredPasswordLength Int32 [ Get ]
public PasswordAttemptWindow Int32 [ Get ]
public PasswordFormat MembershipPasswordFormat [ Get ]
public PasswordStrengthRegularExpression String [ Get ]
public RequiresQuestionAndAnswer Boolean [ Get ]
public RequiresUniqueEmail Boolean [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
public ChangePassword ( String username , String oldPassword , String newPassword ) Boolean
public ChangePasswordQuestionAndAnswer ( String username , String password , String newPasswordQuestion , String newPasswordAnswer ) Boolean
public CreateUser ( String username , String password , String email , String passwordQuestion , String passwordAnswer , Boolean isApproved , Object providerUserKey , MembershipCreateStatus& status ) MembershipUser
public DeleteUser ( String username , Boolean deleteAllRelatedData ) Boolean
public FindUsersByEmail ( String emailToMatch , Int32 pageIndex , Int32 pageSize , Int32& totalRecords ) MembershipUserCollection
public FindUsersByName ( String usernameToMatch , Int32 pageIndex , Int32 pageSize , Int32& totalRecords ) MembershipUserCollection
public GeneratePassword ( ) String
public GetAllUsers ( Int32 pageIndex , Int32 pageSize , Int32& totalRecords ) MembershipUserCollection
public GetNumberOfUsersOnline ( ) Int32
public GetPassword ( String username , String passwordAnswer ) String
public GetUser ( Object providerUserKey , Boolean userIsOnline ) MembershipUser
public GetUser ( String username , Boolean userIsOnline ) MembershipUser
public GetUserNameByEmail ( String email ) String
public Initialize ( String name , NameValueCollection config ) Void
public ResetPassword ( String username , String passwordAnswer ) String
public UnlockUser ( String username ) Boolean
public UpdateUser ( MembershipUser user ) Void
public ValidateUser ( String username , String password ) Boolean

Remarks

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.

Example

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>
See Also

SqlRoleProvider Class Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph