Shining Star Services LLC

Creating a Custom Membership Provider and Membership User utilizing a DataSet Table Adapter - Introduction

by Nannette Thacker

Since I specialize in converting existing ASP Classic websites to ASP.net, the need to connect to an existing database is a major concern. Microsoft provides Membership Providers that ship with the .NET Framework, but for most existing websites, the database schema won't be compatible, therefore requiring the use of a custom Membership Provider.

This series of articles will cover these topics:

  1. Creating the Project and Folders.
  2. The Table Data Structure used for this Tutorial.
  3. Setting up your Web.config file for your custom provider.
  4. Creating your Data Access Layer to your legacy SQL Server 2000 or SQL Server 2003 database.
  5. Creating your custom MembershipProvider class which implements the ValidateUser, GetUser, and CreateUser methods.
  6. Creating a custom MembershipUser class.
  7. Creating a Provider Wrapper Class for Overloaded and Custom GetUser and CreateUser methods.
  8. How to call / use the Custom MembershipProvider and Wrapper within a codebehind page.
This project was written in VB and can be opened in Visual Web Developer or Visual Studio.

There are very few examples of existing Custom Membership Providers on the web. See Microsoft's article on Implementing a Membership Provider. Our example uses SQLClient datasets, but Microsoft illustrates a complete ODBC-based membership provider in How to: Sample Membership Provider Implementation. Our coding will be very similar when setting up the properties and the Initialize function.

Another article which I found very handy is "Writing A Custom Membership Provider for your ASP.NET 2.0 Web Site" by Wei-Meng Lee, which shows how to connect to an Access database with OleDB.

For another technical explanation of the purpose of the Provider models, see Scott Allen's article on Membership and Role Providers in ASP.NET 2.0.

See my article on C# and VB Project: A Tutorial Using Data Sets, Table Adapters, WebForms, Controls, File Upload, Excel Import for further step by step instructions on creating a data access layer and table adapters.

For more technical details on how to create data access layers, see Scott Mitchell's tutorials on Creating a Data Access Layer in VB and Creating a Data Access Layer in C#.

I would like to thank Steven Nielsen for his original coding examples and invaluable assistance in helping me first understand the custom membership providers.

We are now ready to begin Step 1: Step 1: Creating the Project and Folders.

Steps for Creating a Custom Membership Provider and Membership User utilizing a DataSet Table Adapter:

Introduction: Creating a Custom Membership Provider and Membership User utilizing a DataSet Table Adapter.
Step 1: Creating the Project and Folders.
Step 2: Table Data Structure and Web.config for this Tutorial.
Step 3: Creating The DataSet.
Step 4: Creating the Table Adapter Methods for GetUserByLogin, GetUserByUserName, and InsertUser.
Step 5: Creating our Custom MembershipProvider Class.
Step 6: Adding Properties to Our Custom MembershipProvider Class.
Step 7: Creating Our Custom MembershipUser Class.
Step 8: Customizing our MembershipProvider Class.
Step 9: Our Custom RoleProvider Class.
Step 10: Our Master page.
Step 11: Our Cookie Handler class.
Step 12: Our Log In page.
Step 13: Our Register page.
Step 14: Our Log Out page.
Step 15: Our Change Password page.
Step 16: Our Administration page.
Step 17: Loading a Menu Programmatically based on Roles.
Step 18: Our Default page.
Download the ZIP files:
VB: ShiningStarCustomMemberProviderTutorial.zip
© Copyright 1997-2014 Shining Star Services LLC, Nannette Thacker. All Rights Reserved.