-
Dec 29th, 2012, 08:21 AM
#1
Thread Starter
Fanatic Member
Customizing SimpleMembership Provider
I am using simple membership provider in mvc4 application and I can see five tables generated for that. In that i can see username and password are stored on different tables. I want to save username and password on the same table with some custom fields. So I am creating my own Membership Provider by inheriting ExtendingMembership Provider. I have some queries over that.
- My application uses 3-tier architecture(BLL, DAL and Presentation layers) and created 2 areas for account and admin. So here i dont know where to place my membership provider which are then accessed with every part of application for using Authorize Attribute.
- I am overriding this method CreateUserAndAccount, Do i need to implement my own logic for saving user registration datas to database. But i find only some parameters are passed, how to pass my remaining custom fields from view to the controller using the dictionary object ?
Code:
public override string CreateUserAndAccount(string userName, string password, bool requireConfirmation, IDictionary<string, object> values) { throw new NotImplementedException(); }
-
Jan 15th, 2013, 07:32 AM
#2
Re: Customizing SimpleMembership Provider
Membership providers are defined in web.config.
I have to ask why you would need/want to write your own provider, unless it's for a custom data store. Security/crypto is too easy to get wrong and you should not DIY unless you "really" know what you're doing. Is there a reason why you can't use the default provider implementation?
-
Jan 18th, 2013, 01:22 PM
#3
Re: Customizing SimpleMembership Provider
Even if you create your own custom membership provider, you shouldn't use USERS table to store extra fields. You can either implement your own custom PROFILE provider (as I did) or just use a built in provider that comes with ASP.NET Membership Provider. Although I would not recommend it. Built in profile provider is just horrible. Some genius' at microsoft thought it would be very cool to store all properties as ROWS in the table, making this profile provider completely unusable in moderate-to-heavy load environment.
-
Jan 20th, 2013, 06:11 PM
#4
Re: Customizing SimpleMembership Provider
Originally Posted by Serge
Some genius' at microsoft thought it would be very cool to store all properties as ROWS in the table, making this profile provider completely unusable in moderate-to-heavy load environment.
Not even for a moderate load environment. I don't think it's usable in "any" environment.
Your best option for storing custom data related to a user is to make a separate table with the required fields and use the GUID user id as the primary key. Link that to the Users table provided by the default membership provider with FK relation to it's UserId field. No need to bother with creating a custom "profile provider". If you set the FK relation to CASCADE DELETE, then the associated row in your separate table will be removed automatically when a user is removed from the Users table by the membership provider.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|