1

How to tie SqlRoleProvider to "My" user table

I am using asp.net MVC and SqlRoleProvider appears to work out of the box. However I have my own users and roles. I have a user table the has all the user/personalized data. How do I tie the account controller back to my table. My table has a userID and I use that to tie other actions to a particular user.

Would be great if I could use the account controller and after the user logs in, I have their ID.

I have been looking at this but is not quite the same as asp.net mvc

https://web.archive.org/web/20210417083524/https://www.4guysfromrolla.com/articles/121405-1.aspx

Maestro1024
  • 3,173
  • 8
  • 35
  • 52

1 Answers1

1

Not sure if this is the same in asp.net mvc, but we use the SqlMembership provider for authentication with gives us back a MembershipUser object. The MembershipUser instance has a ProviderUserKey property which we map to our own user table's MemberId field (which is different to our internal UserId).

DavidGouge
  • 4,583
  • 6
  • 34
  • 46
  • I see that, so basically after I validate the user I can get their key and use that as "my" id. Would have to tie that in when creating the user also? – Maestro1024 Mar 24 '11 at 23:32
  • I am wondering now, looking at the account controller if I can just merge the account controller in the basic asp.net MVC project with my "create" user controller method. Then I get my personalized data (address,zip,etc) and can use the ProvidersUserKey as a key between my table and the sqlMembership data. – Maestro1024 Mar 25 '11 at 00:26
  • Yeah, spot on. Good luck and glad I could help! – DavidGouge Mar 26 '11 at 17:41