Click here to Skip to main content
Licence CPOL
First Posted 29 Oct 2008
Views 63,101
Downloads 1,499
Bookmarked 50 times

Custom membership provider for the ADO.NET Entity Framework

By | 29 Oct 2008 | Article
Custom membership provider implementation for the ADO.NET Entity Framework.

Introduction

This article describes the implementation of a custom membership provider for the ADO.NET entity framework. The code presented in this article fully complies with Microsoft's provider model design pattern. It also leverages the LINQ to Entities feature introduced with framework 3.5.

Background

It is required to have a basic understanding of the ADO.NET Entity Framework and the ASP.NET membership provider model in order to successfully integrate the presented solution.

Using the code

To configure the attached sample, the following steps have to be taken into account:

  1. Create a database (e.g., EFDataModel).
  2. Run the CreateUserTable.sql script located in the DatabaseScripts solution folder.
  3. Modify the connection string for the Entity Framework in the App.config file of the SmartSoft.EFMembershipProvider.DataLayer project.
  4. Modify connection string for the Entity Framework in the Web.config file of the Web application.

If you want to integrate the custom membership provider into your existing application, you might have to replace the object context EFDataModelEntities within the membership provider class according to your entity model.

Depending on your data model, the method DeleteUser within the membership provider class has to be extended from line 698 onwards in order to delete/mark all user related data.

History

  • 29/10/2008 - Initial article posted.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Michael Ulmann

Architect
Helvetic Solutions
Australia Australia

Member

MCAD, MCPD Web Developer 2.0, MCPD Enterprise Developer 3.5
My company: www.helveticsolutions.com
Hopp Schwiiz Smile | :)

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 2 PinmemberNeerajan Lamsal0:31 22 Apr '11  
QuestionSmartSoft.pfx password? Pinmemberdownatone_7779:22 14 Sep '10  
GeneralMy vote of 3 PinmemberGil Fink0:35 28 Jul '10  
QuestionHow does this compare... PinmemberDLester019:25 18 Apr '10  
QuestionHow can we insert values into FirstName,LastName fields in the Db PinmemberMember 347355311:52 4 Aug '09  
GeneralRole and Profile providers Pinmembershapper9:18 27 Jul '09  
GeneralRe: Role and Profile providers PinmemberMichael Ulmann0:40 30 Jul '09  
GeneralRe: Role and Profile providers Pinmembershapper6:04 31 Jul '09  
GeneralRe: Role and Profile providers PinmemberMichael Ulmann21:43 31 Jul '09  
GeneralRe: Role and Profile providers PinmemberMichael Ulmann23:47 31 Jul '09  
GeneralAdd'l Providers PinmemberJeff Bowman10:19 24 Jul '09  
GeneralRe: Add'l Providers PinmemberMichael Ulmann14:10 1 Aug '09  
GeneralRe: Add'l Providers PinmemberJeff Bowman19:00 1 Aug '09  
GeneralHydrating from EFExtensions Pinmemberjonranes23:24 12 Mar '09  
GeneralRe: Hydrating from EFExtensions PinmemberMichael Ulmann14:10 1 Aug '09  
GeneralMy vote of 2 Pinmemberandrewward2:11 16 Feb '09  
QuestionAre the other providers ready? Pinmemberjetset328:49 11 Jan '09  
AnswerRe: Are the other providers ready? PinmemberMichael Ulmann11:34 11 Jan '09  
GeneralRe: Are the other providers ready? Pinmemberjetset328:22 12 Jan '09  
GeneralRe: Are the other providers ready? PinmemberRoger Jakobsson11:01 13 Feb '09  
GeneralRe: Are the other providers ready? PinmemberMichael Ulmann14:10 1 Aug '09  
GeneralA forgotten thing PinmemberFatihSever15:17 2 Dec '08  
Hi, firstly thanks for your excellent job again.
 
I just finished implementing your provider to my project and tested it. Everything works perfect but only one thing is not working right. Although a user is locked out he or she is able to login. So I have reviewed the code and found a small missing thing. It's in ValidateUser() function:
 
if (CheckPassword(password, user.Password))
       {
           if (user.IsApproved && !user.IsLockedOut)
           {
               isValid = true;
               .......
 

Hope it helps.
QuestionRe: A forgotten thing Pinmemberalibaba06923:37 8 Dec '08  
AnswerRe: A forgotten thing PinmemberFatihSever1:09 12 Dec '08  
GeneralRe: A forgotten thing PinmemberMichael Ulmann17:12 15 Dec '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120604.1 | Last Updated 29 Oct 2008
Article Copyright 2008 by Michael Ulmann
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid