Saturday, August 22, 2009

How to create for Forms Authentication for SharePoint?

Create Database:
First step is to create membership database to save users and their credentials. To create membership database follow steps given below:
1. Open “%windir%\Microsoft.Net\Framework\vx.x.xxxxx” folder. Run aspnet_regsql.exe.
2. And complete the wizard steps(Select Configure SQL Server for application services option from the wizard).
3. Once wizard completed membership database has been created.

Configure Membership Providers:

This will allow us to add the users and roles into the database. To create user and role in database follow steps given below:
1. Create a new web site.
2. Add connection string in web.config file shown below

<connectionStrings>
<remove name="XX_ConnectionString" />
<add name="XX_ConnectionString"
connectionString="Integrated Security=SSPI;
Data Source=<SQLServerName>;Initial Catalog=<DatabaseName>;"
providerName="System.Data.SqlClient" />
</connectionStrings>

3. Now next specify the membership and role providers in the web.config file under <system.web> tag like shown below

<membership defaultProvider="XX_AspNetSqlMembershipProvider">
<providers>
<add connectionStringName="XX_ConnectionString"
passwordAttemptWindow="20"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
applicationName="/"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="1"
minRequiredNonalphanumericCharacters="0"
passwordStrengthRegularExpression=""
name="XX_AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider,System.Web,
Version = 2.0.0.0 ,
Culture = neutral,PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</membership>

<roleManager enabled="true" defaultProvider="XX_AspNetSqlRoleProvider">
<providers>
<add connectionStringName="XX_ConnectionString"
applicationName="/"
name=”XX_AspNetSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider, System.Web,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>

4. Then used ASP.Net Configuration Wizard to create Role and Users.

No comments: