Shining Star Services LLC

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

by Nannette Thacker

Creating our Custom MembershipProvider Class

We want to now create our Custom Membership Provider class. Right click the ProviderClasses folder that you created in Step 1 and select "Add New Item."



Select the "Class" template, name the new provider "SSSMembershipProvider" (or whatever name you desire) and select "Add."



A new class named "SSSMembershipProvider" will open. Type "Inherits MembershipProvider" following the "Public Class SSSMembershipProvider" declaration.



As soon as you type "Inherits MembershipProvider," the screen will be populated with the default properties and functions from the "MembershipProvider" class, allowing you to add coding for each.



Adding the Custom Provider Class to your Web.config file:

Once you have created your custom provider class, you now need to add it to your web.config file. Open your web.config file and add the following element within the system.web section:

<membership defaultProvider="SSSMembershipProvider">
      <providers>
        <clear/>
        <add name="SSSMembershipProvider" 
             type="SSSMembershipProvider" 
             requiresQuestionAndAnswer="false" 
             enablePasswordRetrieval="true" 
             enablePasswordReset="true" 
             description="Custom Membership Provider by Nannette Thacker http://www.shiningstar.net"
             requiresUniqueEmail="true" 
             applicationName="/" 
             passwordFormat="clear" 
             userIsOnlineTimeWindow="15" 
             connectionStringName="SSNetConnectionString"/>
      </providers>
</membership>
In the above provider code, since most older databases do not require a question and answer, we have set requiresQuestionAndAnswer="false" - however, this can be changed to suit your needs. We have set the passwordFormat="clear" to indicate that the password can be read in the field within the table. If your database is setup differently, you may change this. Other valid values are "hashed" and "encrypted."

Next, we will look at adding our Properties to our Custom "SSSMembershipProvider" class.

We are now ready to begin Step 6: Step 6: Adding Properties to Our Custom MembershipProvider Class.

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.