SQL Membership Provider

--------------------------
1. By Default , ASP.NET Membership is enabled
2. Authentication Mode = Forms
3. Default Membership type = SqlMemebershipProvider (specified in machine.config)
4. Default SQLMembershipProvider details
* Connection string = "LocalSqlServer"
* Membership Name = "AspNetSqlProvider"
* Database Server = local instance of SQL Server (MyMachine/SQLEXPRESS)
* Database =aspnetdb
5. Default Role Provider
* Role Provider Name = AspNetSqlRoleProvider

Configure SQL Server 2005 with mixed authentication

----------------------------------------------------
1. Right click on Database Server .
2. Properties > Security > Under Server Authentication > Choose mixed mode
3. This allows user to Log In to SQL Server using Window username or Sql database username
4. Right click DB Server > Restart.

Enable SQL Server Login for Authentication
--------------------------------------
1. Right click Security > Logins
2. Choose login username (used in web.config)
3. Enable Login and Grant Settings
4. This user can be utilized as login in web.config or direct login into SSMS .
5. SQL Sever must be in mixed mode for SQL Authentication.


Configure ASP.NET using SqlMembership Provider with form authentication

------------------------------------------------------------------------
** These configuration can be implement in IIS > web App > properties > ASP.NET > Configuration

A Create SqlMembership Database schema
1. Visual Studio 2005 command Promt > Type aspnet_regsql
2. ASP.NET SQL Server setup wizard is initialized.
3. Choose custom Server = Dev1 , Database = SqlSlim
4. complete wizard step and it will install followings to manage sqlmembership functionalities.

* 11 Tables (aspnet_xxxxxx)
* 40 +- Stored Procedures


B Configure SqlMembership ( subsituted by website administration )
1. In web.config , add connection string

<connectionStrings>
<add name="MySqlConn" connectionString="Data Source=dev1;Initial
Catalog=SqlSlim;User ID=cpyburn;Password=7654321; Integrated Security=SSPI" providerName="System.Data.SqlClient"/>
</connectionStrings>

2. Configure Authentication mode and authorization


<authentication mode="Forms">
<forms name=".ASPAUTH"
loginUrl="Login.aspx"
defaultUrl="MainPage.aspx"
timeout="20" />
</authentication>

<authorization>
<deny users="?" />
<allow users="*"/>
</authorization>

3. Configure Membership
(default is AspNetSqlProvider) to CustomMembershipProvider using MySqlConn.

<membership defaultProvider="CustomMembershipProvider">
<providers>
<add connectionStringName="MySqlConn"
applicationName="MembershipProject"
enablePasswordReset="True"
minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0"
name="CustomMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
requiresUniqueEmail="true"
passwordFormat="Hashed"
/>
</providers>
</membership>

4. Enable and configure role providers to CustomRoleProvider usin MySqlConn.

<roleManager enabled="true" defaultProvider="CustomRoleProvider">
<providers>
<add applicationName="RoleProject"
connectionStringName="MySqlConn""
name="CustomRoleProvider"
type="System.Web.Security.SqlRoleProvider"
/>
</providers>
</roleManager>



C. SqlMembership implementation.
* The configuration is designed to ASP.NET login control for implementation OR
* Create user defined implementation using system.web.security.membership & Roles and such other.

-------------------------------------------------------------
Login
1. Membership.Validateuser( username, password)
2. FormsAuthentication.RedirectFromLoginPage ( UsernameTextbox.Text, NotPublicCheckBox.Checked )

Complete membership implementation.
1. Refer to Membership class methods and properties.

@Copy right of Soon Lim 2006. All Right Reserved