• Sign In
 
  • MSDN Blogs
  • Microsoft Blog Images
  • More ...
Common Tasks
  • Blog Home
  • Email Blog Author
  • RSS for comments
  • RSS for posts
Search
  • Advanced search options...
Tags
  • .NET Framewor
  • .NET Framework
  • Ajax/Javascript
  • ASP.NET
  • CLR
  • Cool stuff
  • DataAccess
  • Debugging/Windbg
  • Hotfix/Service Pack
  • IDEVDataCollector
  • IIS
  • Internet Explorer
  • Italian techs
  • LogParser
  • OT
  • Personal
  • Productivity
  • Random
  • Scripting/ASP
  • Security
  • Technology
  • Tools
  • Troubleshooting
  • Vista/Longhorn
  • Visual Studio
Archives
Archives
  • November 2010 (1)
  • October 2010 (1)
  • July 2010 (2)
  • April 2010 (1)
  • March 2010 (2)
  • February 2010 (2)
  • January 2010 (1)
  • October 2009 (2)
  • September 2009 (2)
  • August 2009 (1)
  • July 2009 (5)
  • June 2009 (1)
  • May 2009 (1)
  • April 2009 (3)
  • March 2009 (3)
  • February 2009 (5)
  • January 2009 (3)
  • December 2008 (5)
  • November 2008 (3)
  • October 2008 (2)
  • September 2008 (3)
  • August 2008 (3)
  • July 2008 (3)
  • June 2008 (5)
  • May 2008 (4)
  • April 2008 (8)
  • March 2008 (4)
  • February 2008 (5)
  • January 2008 (2)
  • December 2007 (4)
  • November 2007 (6)
  • October 2007 (6)
  • September 2007 (8)
  • August 2007 (6)
  • July 2007 (7)
  • June 2007 (10)
  • May 2007 (9)
  • April 2007 (12)
  • March 2007 (8)
  • February 2007 (5)
  • January 2007 (3)
  • December 2006 (1)
  • November 2006 (4)
  • October 2006 (2)
  • September 2006 (9)
  • August 2006 (2)
  • July 2006 (1)

ASP.NET Membership Provider with custom schema

MSDN Blogs > Never doubt thy debugger > ASP.NET Membership Provider with custom schema

ASP.NET Membership Provider with custom schema

Carlo Cardella
23 Sep 2006 1:30 PM
  • Comments 2

PROBLEM DESCRIPTION
===================
Asp.net Membership control issue: when I create users and roles by wizard the default database is sql server express and the file is aspnet.mdf, but in my case I have my own database which store the users detail. I want to use the membership control functionality but don't want to deal with 2 databases; also, I want to add my table to the default database thus changing the schema.
I expect the Asp.net Membership provider to support that change and want to know what should I change in the application code

SUMMARY of TROUBLESHOOTING
==========================
“How to: Use membership in ASP.NET 2.0” at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000022.asp, in particular the section “Using the SQLMemberShipProvider”; basically you need to configure Forms authentication, install the membership database and configure the SqlMembershipProvider.

Step 2. Install the Membership Database
Before you can use the SqlMembershipProvider, you must install the SQL Server membership database.
To install the membership database, log on to your server with an account that has authority to administrate SQL Server (such as the Administrator account). Open the Visual Studio 2005 command prompt, and run the following command:

aspnet_regsql.exe -E -S localhost -A m

Where:
-E indicates authenticate using the Windows credentials of the currently logged on user
-S (server) indicates the name of the server where the database will be installed or is already installed
-A m indicates add membership support. This creates the tables and stored procedures required by the membership provider

Note:
The Aspnet_regsql tool is also used to install database elements for other ASP.NET 2.0 features, such as Role Management, Profile, Web Parts Personalization, and Web Events. Other command-line arguments perform database operations for these other features. You can use Aspnet_regsql without any command line arguments by using a wizard that allows you to specify connection information for your SQL Server and install or remove the database elements for all of the supported features.

Step 3. Configure the SqlMembershipProvider
The Machine.config file contains a default SqlMembershipProvider instance named AspNetSqlMembershipProvider that connects to the SQL Server Express instance on the local computer. You can use this instance of the provider if you are running SQL Server locally. Alternatively, you can specify provider details in your application's Web.config file, as shown here in the following example.

<connectionStrings>
<add name="MySqlConnection" connectionString="Data Source=MySqlServer;
Initial Catalog=aspnetdb;Integrated Security=SSPI;"
/> </connectionStrings> <system.web> ... <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15"> <providers> <clear /> <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider"
connectionStringName="MySqlConnection" applicationName="MyApplication" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" /> </providers> </membership>

 

 

 

 

Make sure to set the defaultProvider attribute value to point to your provider definition. The default value points to AspNetSqlProvider, which uses the local SqlExpress instance.

 

Cheers
Carlo

  • 2 Comments
ASP.NET
Leave a Comment
  • Please add 7 and 3 and type the answer here:
  • Post
Comments
  • Chris
    14 Oct 2008 10:22 AM

    What exactly does this or should this mean or point to?

    Make sure to set the defaultProvider attribute value to point to your provider definition. The default value points to AspNetSqlProvider, which uses the local SqlExpress instance.

  • Carlo Cardella
    20 Oct 2008 4:05 AM

    This is to tell ASP.NET which membership provider to use, so you have to set the "defaultProvider" value to point the provider you have just created

Page 1 of 1 (2 items)
  • © 2012 Microsoft Corporation.
  • Terms of Use
  • Trademarks
  • Privacy Statement
  • Report Abuse
  • 5.6.402.223