Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Code snippet to implement custom membership provider in ASP.NET MVC

Posted on 2010-09-16
5
Medium Priority
?
1,012 Views
Last Modified: 2013-11-08
I want to implement a custom membership provider in an asp.net MVC app.   I am already using forms authentication and  I have a simple database schema for membership/roles that comprises of two tables as only one user can be in one role.

Here are My table schema is in the code snippet below.

I currently check for a user's role by doing

if (User.userRole.roleName == "admin")////

But want to implement custom membership/roles so I need a code snippet that would implement the provider.   T



USER
UserID           Int
RoleID           Int
Username         varchar(100)
AreaID           int
FirstName        varchar(100)
Surname          varchar(100)
Password         varchar(100)
Email            varchar(100)
CreatedOn        datetime
ModifiedOn       datetime
IsAuthorised     bit


ROLES
RoleID           int
RoleName         varchar(100)

AREA
AreaID           int
AreaName         varchar(100)

Open in new window

0
Comment
Question by:ToString1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:roxviper
ID: 33690600
0
 

Author Comment

by:ToString1
ID: 33690644
OK thanks

I am using linq to sql so would want something in that.  I do not want to write stored procedures
0
 
LVL 5

Accepted Solution

by:
roxviper earned 2000 total points
ID: 33690677
0
 

Author Comment

by:ToString1
ID: 33690711
OK that is interesting

In my MVC app I am implementing forms authentication and nothing else

So with this post

http://mikehadlow.blogspot.com/2008/03/forms-authentication-with-mvc-framework.html

Can I implement role based authentication, ie,  I want to partition off admin and superadmin parts of the app
0
 
LVL 5

Assisted Solution

by:roxviper
roxviper earned 2000 total points
ID: 33690764
In fact if you import the right libraries, you can use the same functionality as you used for Web Forms. Personally, I make the same functionality.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question