Create a Form Based Authentication Site in Sharepoint2010

Steps For Creating Form Based Authentication

1. Go to the Sharepoint central administration
2. Open application management; in that open "manage web application" under web applications.
3. In ribbon open new web application is present. Click it. Now one window is open called create new web application
4. Check it's in claim based authentication


5. Enable Form Based Authentication in the same form and give the membership provider name and role manager name.


6. The last thing I configured was to change the identity of the application pool to Network Service.


7. Move the cursor and Click ok. It will take a few seconds to complete and at last it will show the window "application created".


8. Again go to application management and open create site collection under site collections. It will show this page:


9.In this, in the web application, change the site you created already in web application. Give whatever title you used; for example I used sathya.



Then give username and then click ok.

Do step10 or step11. But step11 is best way to do.

10. Open Microsoft SQL Server Management Studio and connect to it. Right-click the database to create a new database.



Give database name as aspnetdb and click ok.

11. Open the Visual Studio 2010 Command Prompt from the start menu and type "aspnet_regsql".







12. Open Visual Studio 2010 and create "ASP.NET Empty Web Site"


Edit the web.config file.

Instead of "<connectionStrings/>" use this code:

    <add name="AspNetSqlProvider"
         connectionString="data source=kirke1; Integrated Security=SSPI;Initial Catalog=aspnetdb;"
         providerName="System.Data.SqlClient" />

In this code give sourcename=your computer name; and then, paste the following code before </system.web>

<membership defaultProvider="AspNetSqlMembershipProvider">


         <clear />

         <add name="AspNetSqlMembershipProvider"


              type="System.Web.Security.SqlMembershipProvider, System.Web,

               Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />



    <roleManager defaultProvider="AspNetSqlRoleProvider">



        <add name="AspNetSqlRoleProvider"



            description="Stores and retrieves roles data from the local Microsoft SQL Server database"             
            type="System.Web.Security.SqlRoleProvider, System.Web,

            Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />



13. Run the project and in the Solution Explorer click the ASP.Net configuration symbol.

It shows


14. Go to security to create a new user and go to role to add roles.
15. To add the connection string

Open the Internet Information Services Manager. Expand the "Sites" node to reveal the web application we created called "SharePoint – sathya".

16. Double-click the Connection Strings feature, and under Actions choose Add. Add a new connection string called AspNetSqlProvider (this is case-sensitive) and click OK.


The server name is your system name database name that you already created.

17. Now, click on the "SharePoint Central Administration v4" node in IIS Manager.
Double-click on Connection Strings and add a new connection string as you did in the previous step, making sure that you are adding the connection string to the Central Administration application this time.


18. Expand the "SharePoint Web Services" node in the IIS Manager and choose the "SecurityTokenServiceApplication" node. Double-click on the connection strings feature and add a connection string just like before.


19. In the IIS Manager, click on the "SharePoint – sathya" node again to reveal the list of features for the web application. Double-click on the "Providers" feature.

Add a new role provider called "FBARoles". Specify the type as "SqlRoleProvider", the ApplicationName as "/", and the connection string name as "AspNetSqlProvider" (available in a drop-down to reduce the likelihood of fat-fingering this).


Add a new membership provider called "FBAMembership". The type is SqlMembershipProvider, connection string name is "AspNetSqlProvider", and the application name is "/".


20. Do the previous step for both central administration and Sharepoint web services. Keep in mind while proceeding with changes in Sharepoint web services, don't make changes directly, for this refer to the following screen shot


21. Edit Web.Config for Central Administration

In the previous section, we added a configuration for a connection string, membership, and roles to our web application. We also need to add these settings for Central Administration so that we can add our forms-based authentication users as site collection owners (among other settings).

We need to make a few small tweaks to the configuration for Central Administration because there isn't a way (that I could find, anyway) to do this using the MMC console:

  1. The defaultProvider for the role section must be AspNetWindowsTokenRoleProvider.
  2. The defaultProvider for the membership section must be our new membership provider, "FBAMembership".

For this right-click the central administration in IIS and click explore.

<roleManager defaultProvider="AspNetWindowsTokenRoleProvider"
    <clear />
    <add applicationName="/"
          type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <add name="FBARoles"
          type="System.Web.Security.SqlRoleProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
          connectionStringName="AspNetSqlProvider" />
<membership defaultProvider="FBAMembership">
    <clear />
    <add name="FBAMembership"
          type="System.Web.Security.SqlMembershipProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
          requiresUniqueEmail="false" />

While we are editing the web.config for Central Administration, there's one more thing that we need to be sure to add. We need to enable wildcard searches for our users when using the People Picker control. This section is located under configuration/SharePoint/PeoplePickerWildcards.

      <clear />
      <add key="FBAMembership"
           value="%" />

22. Edit Web.Config for the Secure Token Service Application

Just like we did with Central Administration, we need to set the default providers for the Secure Token Service Application. Open the web.config file at:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\WebServices\SecurityToken\web.config

You will need to add your connectionStrings section and a web.config section. A partial listing showing the configuration that needs to be added is:

<membership defaultProvider="FBAMembership">
    <add name="FBAMembership"
          applicationName ="/"            
          type="System.Web.Security.SqlMembershipProvider, System.Web, Version=,  Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
roleManager enabled="true"
    <add name="FBARoles"
          type="System.Web.Security.SqlRoleProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

23. Add the user in the site that is present in manage web application under application management in central administration.

For this click that site and go to user policy that is present in the ribbon. It shows one window; in that click "add users". It shows the Add users window; in that select "default" and give "next" and select user from people picker.

Select user that you already gave in create users in Visual Studio. Give permission and click ok.