Setting Up Your Forms Based Authentication Database

B01I0003

I was recently asked if I would cover some topics related to Forms Based Authentication.  The person who requested this information has some specific issues that he wants covered that I won’t be covering for a while because I think there are some other issues that need to be covered first.

One of those is setting up the database.

When I owned my hosting companies, I saw more confusion in this area than just about any other topic that came up.

So here’s the step-by-step process you need to go through to set up your database for Forms Based Authentication.

In your hosting company’s control panel, create the SQL database.  You’ll want to create a database with a size of at least 10 meg with 5 meg allocated to the log file and 5 meg allocated to the database.  You’ll also want to make sure the user you attach to the database has DBO rights.  You may need to contact support to enable this.

Next, you’ll want to run aspnet_regsql.exe which you can find under c:\windows\Microsoft.NET\Framework\v2.0.50727.  This will provide you a wizard interface and will ultimately create the appropriate tables for you. The wizard is self explanatory, so I won’t repeat it here except to say that you’ll want to enter your connection information to connect to the server you just created your database on, not one of your databases locally.

Next you’ll need to add the connection information to your web.config file for the application you are setting up Forms Based Authentication for.

<connectionStrings>
 <remove name="LocalSqlServer"/>
 <add name="LocalSqlServer" 
  connectionString="Data Source=sqlserverGoesHere;
    Initial Catalog=YourDatabaseName;
    Persist Security Info=True;
    User ID=YourSqlUserID;
    password=YourSqlPassword" 
  providerName="System.Data.SqlClient"/>
</connectionStrings>

The “remove” element is needed because typically the machine.config file on the server has its own entry that you won’t be using.

Unfortunately, you’ll need to create your own UI for adding users and assigning them to roles.  It isn’t that hard to do and once you’ve done it you can move the administration controls from project to project.  If I were you, I’d create the control set once in a special sub-directory so that I could move it from project to project.

Other places talking about Forms Based Authentication:

Single Sign-On Across .Net Web Apps Using Forms Based Authentication – Achieving single sign-on capabilities using Forms Based Authentication is much easier than I had initially expected, yet it took awhile to find the exact settings required. To get FBA working in SharePoint click here for a good starter …

Forms Based Authentication and Active Directory – I recently had to configure Forms Based Authentication for our website (in my case SharePoint, but the same would apply to a plain ASP.NET website) and I wanted to configure it to use Active Directory for the account storage. …

Avinash: Configuring Forms Based Authentication (FBA) in SharePoint – 6) Change Authentication Provider for Forms based site. 7) Change configuration files settings. 8) Change policy for Web Application 9) Add users/roles as site administrator (Primary and Secondary). 10) Check Forms Based Authentication …

Easy-Bake Forms Based Authentication – In a hosted environment I often see situations where a customer wants to quickly and easily add Forms Based Authentication to their SharePoint Web Application. Unfortunately, it is neither quick nor easy to add this functionality, …

Like this Article? Subscribe to get every article sent to your email.

Related Post

  • Forms Authentication – Creating UsersForms Authentication – Creating Users Last week we installed the tables into our database and set up the database connection so that we could implement forms based authentication. This week, we need to put into place a way […]
  • Determine The Role of a User in ASP.NETDetermine The Role of a User in ASP.NET There are several controls that allow you to display content based on the role a user is in, including: - LoginView - LoginStatus And the web.config file allows us to control which […]
  • ASP.NET Authentication – Multiple Domains w/ Same ApplicationASP.NET Authentication – Multiple Domains w/ Same Application In our series about ASP.NET authentication so far we’ve covered all the rather normal cases where you’d want to have the ability to log into different domains attached to the same […]
  • DotNetNuke Modules – Creating Base ModulesDotNetNuke Modules – Creating Base Modules Now that we have DotNetNuke installed into Visual Studio we can go ahead and create our first modules. Actually, creating the modules is pretty simple. But it is even easier to do it […]
  • Unique SQL Logins and SqlMembership ProviderUnique SQL Logins and SqlMembership Provider There are cases where it is advantageous to have a separate sql login for each user login who will be editing your database.  If you are using Windows authentication, this is not a problem […]

About Dave Bush

Dave Bush is a .NET programmer and Certified ScrumMaster who is passionate about managing risk as it relates to developing software. When he is not writing or speaking about topics related to Application Lifecycle Risk Management (ALRM), he is an example to his peers as he develops web sites in the ASP.NET environment using industry best practices.