0

I have an enter image description hereexisiting database which I used to create a Model usign the Database first approach. Please refer to the database diagram.

In my solution file, I have a Class Library of the model which has an ADO.NET connection to the database & and I a ASP.NET MVC 3 web application.

The funcitonality that I'm trying to get here is that - the information displayed once a user logs in is different for every user. How do I link the user login page to the 'user' table of the database? Is it directly using the connection string or do I need to go through the model that I created using the Database?

Kristina
  • 19
  • 5
wackytacky99
  • 614
  • 1
  • 14
  • 33

1 Answers1

1

Add a field to your User table called "ProviderUserKey" or MembershipUserID, or something similar of type uniqueidentifier. You then call Membership.GetUser().ProviderUserKey and use that in your where clause of your User Table to select the correct User record based on the logged in user.

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
  • That is right, but how do I link the user login view with this user table for user authentication? – wackytacky99 Jan 27 '12 at 01:07
  • @mvador99 - I don't understand. What does your table have to do with user authentication? Authentication is handled by the Membership system, and has nothing to do with your table. Or do you mean you want to use your table instead of the asp.net membership tables? If that's the case, then you need to write a custom membership provider. – Erik Funkenbusch Jan 27 '12 at 01:10
  • Yes I want to use the User table instead of the Membership tables. What do you mean by a custom membership provider? – wackytacky99 Jan 27 '12 at 01:39
  • @mvador99 - I mean, create a custom membership provider. http://msdn.microsoft.com/en-us/library/ie/f1kyba5e.aspx – Erik Funkenbusch Jan 27 '12 at 04:04
  • Can I use the regular Membership provider and then use the User table to store additional information? If yes, will that allow me to filter the SalesOrders and other records by user? – wackytacky99 Jan 27 '12 at 04:09
  • @mvador99 - yes, that's what I thought you wanted to do at first, and it works well. – Erik Funkenbusch Jan 27 '12 at 04:12