Click here to Skip to main content
Click here to Skip to main content

How to Configure Form Based Authentication (FBA) in SharePoint 2010

By , 23 Mar 2012
 

Introduction

This article explains step by step information on configuring Form Based Authentication (FBA) in SharePoint 2010. This article would be useful for developers/designers/architects and those who want to implement form based authentication (FBA) for their SharePoint 2010 sites as a business requirement.

We cannot use the classic / basic claimed based authentication for all business scenarios. I was recently working on a consumer portal or product selling site where form based authentication is most appropriate. This article resolves authentication issues by configuring a SharePoint 2010 site with form based authentication.

Difference between MOSS 2007 and SharePoint 2010

There is no huge difference in configuring FBA for a MOSS 2007 site and a SharePoint 2010 site. You cannot implement FBA for a SharePoint 2010 class authentication site. FBA can be implemented only for a claims authentication site in SharePoint 2010.

In MOSS 2007, it is required to configure the web.config file of the FBA site and Central Administration site. In SharePoint 2010, it is required to configure the web.config file of the FBA site, Central Administration site, and the Security Token Service (STS) web.config file. STS is one of the next generation Single Sign On services used to store credentials of an application in SharePoint 2010.

I have also written article on enabling FBA in a MOSS 2007 site in CodeProject and Blogger and is available here. CodeProject: http://www.codeproject.com/Articles/19055/Form-Authentication-for-MOSS-2007-Site, Blogger: http://nagendra-gunaga.blogspot.in/2012/03/form-based-authentication-fba-for-moss.html.  

Steps to Configure FBA in SharePoint 2010 

Below are the steps required to configure FBA in SharePoint 2010. I will be using MS SQL database as membership store for users.  

A) Setting up ASP.NET Forms Authentication User and Role Data Source 

1. Create Database 

2. Configure Membership and Role Provider 

3. Create User

B) Create Web Application and Site Collections

C) Configure Web.Config file 

1. Configuring FBA web application web.config file

2. Configuring Central Administration web application web.config file

3. Configuring Security Token Service web.config file

D) Adding User Policy to the FBA Web Application

E) Verification Steps 

A) Setting up ASP.NET Forms Authentication User and Role Data Source 

This section explains creation of database which is used to store user's information such as credentials and roles which is used for Form Authentication. This section also explains the configuration of Membership and Role providers in the web.config file and creation of users using ASP.Net configuration wizard. This article shows creating a user and which will be used for testing Form Authentication later.

1. Create Database 

To create database, Microsoft has provided a tool/ utility called

aspnet_regsql.exe that creates a database for us. This utility can be found in %windir%\Microsoft.Net\Framework64\v2.0.50727 folder. Please see the image below: 

Executing aspnet_regsql.exe file will open ASP.Net SQL Setup wizard that will walk through creating the ASP.Net database. I have added the database name as FBANetDB and configured it for windows authentication. Please see the image below:

Click on Next button. Please see the image below:

Select Configure SQL Server for application services option and click Next button. Please see the image below:

Click Next button. Now the database FBANetDB is created successfully. Please see the image below:

2. Configure Membership and Role Provider 

In the previous section, database is created successfully. Now we need to add a user in to database. Using ASP.NET Configuration Wizard, users can be added the database. This can be achieved by creating web site that will allow us to add the users and roles and also ensure the database connection strings, membership and role providers are correctly configured before we bring SharePoint in to equation.

Below steps explains creating web site and configuring membership and role providers and executing ASP.Net Configuration Wizard.

a) Open Visual Studio 2010 and select File ? New ? Web Site. In the New Web Site dialog, select the ASP.Net Web Site template and enter the location to store the web site files. Please see the image below:

You can choose any location whichever is comfortable for you. web.config file will be added to project automatically.


b) By default, you will see a <connectionStrings/> node within <configuration> node. Specify the connection string to the database which has been created in the previous section. Please see the image below:

 

I have mentioned server as GUNAGA1. This is the server in which SQL Server 2008 is installed. Please mention the respective server name.

Also add the membership provider and role provider within <system.web> tag. See the below image for more information.

 

c) Save web.config file and launch the ASP.Net Configuration Wizard by clicking on Website ? ASP.Net Configuration. Please see the image below:

  

d) Set the authentication type in the above wizard. To do this, click Security link. In the Security tab, under Users section, click Select authentication type link. Select From the internet option and press Done button which is available in the bottom right corner. By selecting this option, which means that site will use form authentication to identify users. Please see the image below:

  

e) To test the membership and role providers, click on Provider tab. In the Provider tab, click on Select a different provider for each feature (advanced) link. Select right / correct membership and role provider and click Test link to ensure that providers are communicating to right database.

At this point, we configured web.config file with connection string and providers information. Also we tested the providers with the database. Next section will explain adding users to database.

3. Create User 

a) To add users, click on Security tab. In Security tab, under Users section, click Create user link. Here I am adding user as testFBA and password as password which will be used for testing form authentication later. Please see the image below:

  

Now we have created a user successfully. Do not worry about creating roles at this time and will be explained later.

B) Create Web Application and Site Collection 

Follow the below steps to create web application and site collection.

a. Go to Central Administration ? Application Management ? Select ‘Manage Web Application’ link present under ‘Web Applications’ section.

b. Click on ‘New’ option in the ribbon.

     1. See the below image for ‘Authentication’ and ‘IIS Web Site’ section.

         

     2. See the below image for ‘Security Configuration’ and ‘Claims Authentication Type’ section.

          

     3. See the below image for configuring ‘Sign In Page URL’ and ‘Public URL’ section.

        

     4. See the below image for configuring ‘Application Pool’ and ‘Database Name and Authentication’ section.

         

     5. Create Site Collection after creating web application. Select the template whichever you want to create site collection.

C) Configure We.Config file

1. Configuring FBA web application web.config file 

Open FBA web application web.config file and add the below entries.

     a. Add Connection String. Connection String has to be added after </SharePoint> and before <system.web> tag. See the below image for more information.

           

     b. Add Membership Provider and Role Provider

         

2. Configuring Central Administration web application web.config file 

Open Central Administration web application web.config file and add the below entries.

     a. Add Connection String. Connection String has to be added after </SharePoint> and before <system.web> tag. See the below image for more information.

           

     b. Add Membership Provider and Role Provider

         

3. Configuring Security Token Service web.config file 

Open Security Token Service web.config file from %Program Files%\Common Files\Microsoft Shared\web server extensions\14\Web Services\SecurityToken location and add the below entries.

a. Add Connection String. Connection String has to be added above <system.web> tag. See the below image for more information.

b. Add Membership Provider and Role Provider

D) Adding User Policy to the FBA Web Application 

Follow the below steps to add user policy to the web application.

a. Go to Central Administration ? Manage Web Applications ? Select the FBA web application and click on ‘User Policy’ option in the ribbon.

b. Click on ‘Add Users’ link and select ‘Default’ as the zone and click on ‘Next’ button.

c. Type the user name created in ‘Create User’ section in the ‘Users’ textbox and click on people picker icon. You should see the user name get underlined in the ‘Users’ textbox.

d. Follow the verification steps to test form based authentication.

E) Verification Steps 

1. Go to FBA SharePoint site and select ‘Forms Authentication’ option.

2. Enter User Name and Password and select ‘Sign In’ button.

3. You should be redirected to home page.

Comments 

Provide your feedback if this article is helpful to you and post your issues/queries if any.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

NagendraGunaga
India India
Member
I have about 10 plus years of experience in professional software development with extensive involvement in Web based Object-Oriented, Multi-Tiered application design and development. I have experience in working with Content Management System and Portal Management System tools like SharePoint and also had experience in Integration of SharePoint with Commerce Server, Exchange Server.
 
Currently I am working in a Software firm Hewlett Packard Global Soft Private Limited as SharePoint Solution Architect located in Bangalore, India. My main responsibilities include designing SharePoint solution for a large enterprise product, automating SharePoint Deployment, Developing WebParts, Managing SharePoint Authentications. You can contact by emailing me at nagendragunaga@gmail.com

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionMysqlmemberMember 797153422 Oct '12 - 23:41 
It's possible for mysql because for Asp.net is it. ?
QuestionA small tipmemberIris_8427 Sep '12 - 7:55 
Hi, I've made a custom login page FBA web app and my current problem is that all users currently login with full control, given that I assaigned that for them to be able to see the login page at all in the first place but as it turns out that was not the best thing to do. I was suggested to specify the login page in the web config so anonymous users could access it without need for permissions, any idea how I can do that?
I'm a beginer btw if that wasn't obvious already.
QuestionCan I use an existing table of users?memberpscad5 Jul '12 - 4:26 
I have implemented FBA, and it seems to work against the dbo.aspnet_Membership table, but I would like to authenticate against an existing users table, say dbo.tblUsers. Is this possible?
 
Thanks
GeneralLogin With Webservicemembernipeshshah22 May '12 - 3:23 
Hi,
 
Thanks for sharing detail explanation of FBA. I want to use Sharepoint 2010 using webservice in FBA Enabled Sharepoint service. I use your nice explanation for making my fba enabled site. And then Authenticate web services using explanation as given here.
 
http://nipeshshah.blogspot.in/2012/05/fba-form-based-authentication-login.html[^]
 
Thanks for nice explanation.
Questionlogin page is not coming up in Share Point 2010memberMember 465470415 May '12 - 10:17 
Hi everyone,
 
I am working on migration process from moss 2007 to sharepoint 2010. I have one site and wsp file. I have created site in sharepoint 2010 and deployed wsp file against to that web site.
 
I have created and configured FBA site in sharepoint 2010. but still my login page is not appearing in my web site.
 
Can anyone please help me, did I missed any step?
 
Regards,
MNK
QuestionServer Error in '/' Application - Implementing FBAmemberNarshimha1 May '12 - 21:23 
I have followed the steps provided in this article (How to Configure Form Based Authentication (FBA) in SharePoint 2010 to implement Form Based Authentication (FBA) in Sharepoint 2010.
I have successfully implemented the Step A and Step B of the article.
While implementing the Step C (i.e. Configure Web.Config file), I received the following error after configuring the web.config file of FBA web application.
Error: Server Error in '/' Application
Could you please let me know what would be causing this error?
 
Thanks,
Narshimha
QuestionServer Error / Configuration Errormemberdmddgl0119 Apr '12 - 23:48 
Thank you for your very comprehensive and recent article, on FBA in Sharepoint 2010.
It is nice to see new articles being published and shard with other users.
 
I tried to implement this guide, using the steps you are outlining in the article and whenever I reach a certain stage I get an error message, following the modifying of the web.config file. After modifying the web.config file, then I try to run the ASP.Net Configuration Wizard, as suggested (at stage 2c) and I get the following error message, when trying to load the website. The message details are:- "Could not load file or assembly System.Web, Version=2.0.3600.0, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."
 
I followed all of your steps, as I would like to get FBA working in Sharepoint, for my organistation.
 
Do you happen to know, what would be causing this error?
 
I look forward to hearing from you.
 
regards,
 
Dan.
QuestionFBA for public sitememberpaddy nair10 Apr '12 - 7:35 
I could get this done for setting up of FBA on intranet site. But when I try to access the same site publicly , I am not taken to the default login page (_login/default.aspx). Instead windows challenge pops up. Am I missing anything ?
AnswerRe: FBA for public sitememberNagendraGunaga19 Apr '12 - 7:06 
Did you follow the steps properly? Also see the IIS settings. Also validate the both membership and role provider settings.
Regards,
Nagendra Gunaga
Tel:+91 9741877550
Email:nagendragunaga@gmail.com

QuestionPerfect Timing - All new to me.memberGio12844 Apr '12 - 13:34 
Hello NagendraGunaga,
 
Thank you for NOT deleting this. I am a SharePoint admin but have very little coding skills. I have been trying to put together a FBA site and this article was perfect for me. While this topic may have been covered endless times in endless publications, your post was the one that allowed my to implement a working Forms based website and to help me understand how it all worked.
 
Thank you!
Gio
AnswerRe: Perfect Timing - All new to me.memberdmddgl0120 Apr '12 - 0:06 
Hi Glo, Did you follow the exact same steps as outlined, in the article.
 
I am trying to implement FBA in my own organisation but I get an error message when I get as far as point 2c, in the article. i.e. Server Error referring to the PublicKeyToken.
 
I just wondered did you come across this error message, when you were impmenting it?
I used exact same code, as provided, in the examples.
 
regards,
 
Dan
General[My vote of 1] Too late, nothing newmvpMark Nischalke23 Mar '12 - 8:31 
This subject has been covered by many, many, many other sources and you have added nothing new to the dicsussion.
 
Just like the MOSS 2007 version of this 2/3 of this article covers the ASP.NET membership database and has nothing to due with SharePoint besides being covered to death by many other resources.

Failure is not an option; it's the default selection.

GeneralRe: [My vote of 1] Too late, nothing newmemberNagendraGunaga23 Mar '12 - 21:01 
Dear Sir,
 
I agree that FBA is covered in many sources but their implementation may be different. Not all article talks about single data source. They are different such as LDAP, custom DB, ASP.Net DB etc.... It is also true that you cannot get opportunity work on all SharePoint APIs in one single project. Based on project requirement, you will get an opportunity to work on multiple aspects of SharePoint in real life. I always write article based on my project experience i.e. what I learnt new thing from this project. It is quite common that same article might available in multiple sources bcoz it's a big world and every one has their own way of expressing their experiences. After reading your comments, It strike one thing in my mind that it is not required to write article and publish it. Because, everything is available in Microsoft site.Why do we need other sources?
Regards,
Nagendra Gunaga
Tel:+91 9741877550
Email:nagendragunaga@gmail.com

GeneralRe: [My vote of 1] Too late, nothing newmvpMark Nischalke24 Mar '12 - 4:38 
NagendraGunaga wrote:
I always write article based on my project experience...

Then you have very limited experience
 
NagendraGunaga wrote:
... i.e. what I learnt new thing from this project

and you don't learn very well since you repeated ASP.NET membership database implementation from previous article.

Failure is not an option; it's the default selection.

GeneralRe: [My vote of 1] Too late, nothing newmemberNagendraGunaga24 Mar '12 - 8:01 
Dear Sir,
 
I don't want to discuss further on this. I know my technical strength very well. If you think that this article is not up to the mark, please delete it. I will stop posting in code project going forward.
Regards,
Nagendra Gunaga
Tel:+91 9741877550
Email:nagendragunaga@gmail.com

GeneralRe: [My vote of 1] Too late, nothing newmvpMark Nischalke24 Mar '12 - 14:31 
NagendraGunaga wrote:
I know my technical strength very well

Try to expand your skills. You have written two articles on the same subject with each sharing the same 3/4 about ASP.NET membership database, which hasn't changed between 2007 and 2010. So far you have demonstrated very weak skills.
 
NagendraGunaga wrote:
please delete it.

It's your article, if you think it is best to delete it then do so.
 

NagendraGunaga wrote:
I will stop posting in code project going forward

You don't have to stop posting. Just post better articles, or accept critiques.

Failure is not an option; it's the default selection.

GeneralRe: [My vote of 1] Too late, nothing newmembernlvraghavendra4 Feb '13 - 3:11 
It is completely arrogant of you to say that the author has weak skills. Just based on an article, that too which delivers the right information, if you rate the author to be weak, I'm sorry, you have to grow.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 23 Mar 2012
Article Copyright 2012 by NagendraGunaga
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid