{infiniteZest}
// Articles. Tutorials. Utilities.
Home  |   Search  |   Login  
Categories Skip Navigation Links
New / All
AJAX
Apple
ASP.NET
.NET
Git
Google / Android
Python / IronPython
Miscellaneous
SQL Server
Setting up the authentication (users and passwords) database in ASP.NET 2.0
Summary
By default SQLEXPRESS is used as the database that contains the membership information. Some thoughts in this regard.
 
Table of Contents

In Summary:

 

By default, the membership database is setup in the App_Data folder of your application; name of the database file is ASPNETDB.MDF. It is very likely that you want this set of tables to be in your regular SQL Server database for any number of reasons:

  • You want all the user information tables to be near your other (application-related) tables, so you can maintain some relationships between these tables.
  • You don’t want multiple databases: one for just the user data and another for application data
  • Your hosting company might not provide the ability to use SQLEXPRESS databases for security reasons

So, how would you set up the membership and roles related tables in your regular SQL Server databases?

Check out the following links for step-by-step instructions:

Scott Guthrie’s blog post on "Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005":

http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx

It also appears on MSDN (better formatting):

http://msdn2.microsoft.com/en-us/aa479307.aspx

In Summary:

Use aspnet_regsql.exe from command line and follow the instructions.

Following commands should work (choose the appropriate .NET Framework directory)

cmd
cd C:\Windows\Microsoft.NET\Framework\v2.0.50727
aspnet_regsql.exe

-Using the above utility you can either install or remove the set of database objects (tables, views, stored procedures) used for membership, roles, etc. So, don’t worry about accidentally cluttering your db -- if you installed this by mistake, you can remove them as well.

After you successfuly run the above utility, you will see the following in your database:

  • 11 new tables with names prefixed with aspnet_
  • 9 new views with names prefixed with vw_aspnet_
  • Several new stored procedures prefixed with aspnet_

Now, how does your application know where are these membership related tables installed? Setup a connection string for "LocalSqlServer" (not the most intuitive name, but that’s what’s used by Microsoft).

<remove name="LocalSqlServer"/>

<add name="LocalSqlServer" providerName="System.Data.SqlClient" connectionString="Data Source=;Initial Catalog=;Persist Security Info=True;User ID=;Password=" />

</connectionStrings>

Now you can use the Web Site Administration Tool to further setup the users, roles, etc.

Bookmark and Share This

More Articles With Similar Tags
icon-CreateUserWizard-newuser.jpg
You have added the extra controls to the CreateUserWizard to collect additional information from the user at the time of new account creation. This article discusses how to save that extra information to the database.
icon-roles-dbdiag.jpg
This article looks at adding a role to the user that has been newly created via the CreateUserWizard.
icon-CreateUserWizard-extended.jpg
This article discusses the CreateUserWizard and looks at extending the default user interface provided by it.
icon-aspnet_membership_dbdiag.jpg
This article discusses the difference between authentication and authorization. It also discusses how the data required to support each of these features is stored in the database in ASP.NET 2.0 sites.
About  Contact  Privacy Policy  Site Map