Question

I've tried searching this for days and can't seem to find an adequate answer so I'll ask here.

I'm building an asp.net Membership website.

What I want to do is:

Allow a user to create an account - say UserA I then want to allow UserA to create "sub accounts" tied into his account, but with different roles as well as different login names (I'll be using email address as the login name)

UserA would be the account admin of sorts. UserA's sub accounts would be less "adminish" than UserA, but any data that they write to my DB (Entity Framework) would still be tied to the main UserA account which will be referenced to my tables via Membership.GetUser() API calls.

So 2 questions:

1) How would I reference the Membership tables in my EntityDataModel using DB First (I already ran the aspnet_regsql.exe)

2) How would I need to go about allowing UserA to create his own sub users?

Here's an image of my custom tables:

[MasterAccountUser]
MasterAccountId = aspnet_Membership.UserId
AccountNumber = autoincrement number

[UserAccount] - subaccount of [MasterUserAccount]
AccountId = aspnet_Membership.UserId (if I have to have  each user create their own)
MasterAccountId = aspnet_Membership.UserId (but the same one as the [MasterAccountUser]

enter image description here

If this is too vague, let me know and I can expand.

Était-ce utile?

La solution

I was able to get this to work.

Basically, you just do the standard aspnetdb.mdf with all the in-place security features. Then you simply add a table with the same fields, and then you reference the

MembershipUser.GetUser(Page.User.Identity.Name);

So you own table will have a "masteruser" with this User.ProviderKey. Every "sub-user" then has the SAME masteruser guid on their record so that they all fall under the same account.

If anyone want more details on how i got this to work, i can happily provide them.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top