Shining Star Services LLC

Creating a Custom Membership Provider and Membership User utilizing a Data Set Table Adapter - Step 2

by Nannette Thacker

Table Data Structure for this Tutorial

The below screenshot depicts my data structure for my existing "Users" table from my existing database. This structure does not match the default membership user structure provided by Microsoft, so this is why we have to setup a custom MembershipProvider.

Our table consists of 9 columns as shown below. For this example, you will need to create a database and add a Users table with the following fields in order to run the sample files. Or simply use this as a guideline to connect to your existing database and alter the fields accordingly. Start small and just use a few fields from your user/member table, and then add all needed fields once you get the hang of it.



Creating a Connection String within Web.Config

Now you are ready to setup your connection string within your web.config file. You may skip this step and allow the Data Set to add the connection string to the web.config file for you.

When you created your project, a web.config file was also created for you. You may keep the default file as created and alter it, or set it up using your own desired settings. Below you see I have added a connection string to the database in the App_Data directory.

<add name="SSNetConnectionString" 
    connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|
    \SSSDatabase.mdf;Integrated Security=True;User Instance=True" 
    providerName="System.Data.SqlClient"/>


Alternately, you may connect to a remote database:



The above image utilizes the following connection string:
<connectionStrings>
    <add name="SSNetConnectionString" connectionString="Data
    Source=66.66.66.66;Initial
    Catalog=SSNET;Integrated Security=True"
    providerName="System.Data.SqlClient" />
</connectionStrings>
Please alter it by changing the "name" to your desired name, the "Data Source" to your IP address or server name, and the "Catalog" to the name of your database catalog.

If you intend to use Windows authentication to access your database, also add the following element to your web.config file within the system.web section:

<identity impersonate="true" />
For more details about this element, please see the section on "Sharing the Same Windows Domain" in this article on Configuring an ASP.NET 2.0 Application to Work with Microsoft SQL Server 2000 or SQL Server 2005.

We are now ready to begin Step 3: Step 3: Creating The DataSet.

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-2017 Shining Star Services LLC, Nannette Thacker. All Rights Reserved.