views:

39

answers:

1

Hi, We're hitting a good number of walls and stumbling blocks as we create our custom Membership based upon MembershipProvider, MembershipUser and RoleProvider etc.

We have a number of interesting requirements and Membership Provider doesn't appear to be helping us much in achieving them:

  • Users may have multiple Logins.
  • Users don't have a username directly (but may have a login that has a username).
  • Users have one unique reference (currently an auto-incrementing primary key).

To implement this, we have two tables: Users which has a one-many relationship with Logins.

This effectively means we have a User who (in a hypothetical world) can log in via their Active Directory Account automatically (when possible) and via an OpenID or a Username/Password combination alternatively. We'll also have some users who may not have an AD account.

I had initially tried re-purposing the Membership classes by creating: - CustomMembershipProvider - CustomMembershipUser - CustomRolesProvider

But all my fighting against it has just given me black eyes and bruises, it really, really wants a username!

Have I gone about this the best way? Should I be starting from stratch and not inheriting anything? Should I be basing it on the IProvider class? Or maybe the GenericPrincipal and GenericIdentity classes? Or am I just plain missing something with MembershipProvider?

I want to keep the end programming experience as easy as it is for the out-of-the-box membership stuff, e.g.

Membership.GetCurrentUser();

And avoid a less than simplistic end-coder experience...

A: 

I had similar experience and decided to give all users a common Membership for role checking, etc and map it to differenct AuthenticationProviders (OpenID, AD, Membership Providers, etc) so they can be authenticated differently.

twk
How do you mean that you had a common Membership, but with different providers? That sounds similar to what I want to achieve, but a requirement is definitely to not have to define multiple roles and profile providers for what is effectively still just one user. Does this make sense?
Amadiere
Each user must have Memebrship profile, otherwise cannot be authorized by Roles.But this profile refers to authentication providers (one to many), so the user can login using different ways. The Membership Provider reference is a self reference to the profile (it is the same provider).
twk