views:

148

answers:

2

My asp.net mvc site needs some kind of authorization but it is rather different than the usual concept of users and thus membership. It will be used more for preferences then for authentication actually. Accounts without any password should be possible (and will initially be the only type) and an account can also be used by multiple users at once. Depending on the user group it could be for example that all users of a certain region get a shared account. This is a decision from the client('s marketing division) and is not up for discussion.

A certain landing page takes (only) a userId in the url that will load up an account which in turn has some preferences linked to it that can be used throughout the rest of the site.
If a user doesn't start at the landing page or the sent accountId doesn't match a record in the system, he/she will be assigned the default account that has default preferences.

I was thinking of not re-inventing the wheel (somebody should find a new expression for this) and use the asp.net Membership system. But the whole system is based around required passwords, email and single sessions per user, which are all things I can't provide. Because the situation is a bit unconventional I thought a custom MembershipProvider etc would be in place. But it seems the gist of this is inheriting from the regular Membership classes. The methods of these classes all require things I am not needing.

Any suggestions

+1  A: 

You could use the standard Membership provider and using the Built in .Validate() method sending the Username and a Password that is "standard" for all accounts without authentication.

Have 2 different User Controls 1 for "Validated Login with Password" and one for "Share Account without password", each uses Membership-login but the latter needs to have a bit set on the field of the member that says "Public Account = True / 1 "

Good luck, seems like a fun project, would be cool to see the outcome ;)

By the way, you don't need to share the session, or you could, just stored the session in the database and map the session to a user instead of a cookie, might work?


As requested i'll elaborate on different user controls. Briefly i would have 2 Controls, one maybe called GlobalLogin and one called UserLogin, where GlobalLogin displays a Form which only has the Username, when submitted this will trigger a function that uses, as i stated before, a function which calls the Validate method in the Membership provider, with a pre-set password.

As a reflection, see all "Not logged in with password"-users as anonymous and treat them the same way, the only thing that is different is that they can access user-specific areas. This control also needs to check that a certain field in the database is set, such as a "Allows Globally Used Account Without Password"-field, where in this case, the bit / boolean needs to be true for this login to be accepted.

Now to the other part, the Control which handles Password Protected Accounts, this requires both Username & Password and this calls the Validate with these settings. Now, remember that when logged in with password, you can change your password, this SHOULD NOT be possible with a Global Account, because then your global password wouldnt work :)

Filip Ekberg
Thanks for the input. Could you elaborate on your second paragraph a bit? What do you mean with 2 different user controls?
borisCallens
Is that sufficient? :)
Filip Ekberg
yes, thanks. I will check if this option is viable with my current requirements :)
borisCallens
A: 

There is detailed information on the Membership Provider at http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx. Basically you need to create new provider, or derive from the existing, and overload the ValidateUser method to always return true.

Matthew