Link to home
Create AccountLog in
Avatar of ToString1
ToString1

asked on

Implement custom membership provider with MVC2 sql server

I want to implement a custom membership provider and have 3 database  tables

User
UserID, name, RoleID

Role
RoleID, roleName

UserRoleManyToMany
UserID, RoleID

I don't really want a link to another site but just an oviewview of how to implement please
Avatar of mrjoltcola
mrjoltcola
Flag of United States of America image

First off, are you sure you need a custom provider? Often, if you have decided not to use the Microsoft provider, it is simpler to forego the membership interface altogether.

Otherwise, the best place to start is the sample implementation from MSDN.

http://msdn.microsoft.com/en-us/library/44w5aswa.aspx

Essentially, you need to implement MembershipProvider. You can stub out many of the methods, but must implement the ValidateUser() method, and Initialize() methods. If you are trying to leverage the IIS Membership management gui, then you will need to implement more to allow password resets, lockout management, etc. All of these basically are low level data access layer boilerplate code to fetch / update / store user records from your tables.

Implement the interface by creating your custom class as show in the sample code, configure your web.config (also shown in the sample) then go from there, and ask back here for more specific answers.
Avatar of ToString1
ToString1

ASKER

OK thanks

Could you give a quick snippet of stubbing out methods and say just implementing ValidateUser() method?
ASKER CERTIFIED SOLUTION
Avatar of mrjoltcola
mrjoltcola
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer