[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

SimpleMembershipProvider UserID / Program Database UserID Translation Table?

Problem: I'm dealing with 2 different databases,
  1 -  membership & roles
  2 -  My program database

The 1st database is the MVC4 SimpleMembershipProvider. Very simple login and very little user info stored. I know how to get the current logged-in user name like so:

string userName = HttpContext.User.Identity.Name;

The 2nd database contains actual Program data and some user info used in the actual web site for our Products inventory. It has  the UserID i really need to persist for use in several controllers. Inserts, Updates, Deletes all rely on this UserID.

So the logged-in UserID or Username and Role is not the same as our actual Program database.

Q. Do need a 'translation table' to cross-reference the WebMatrix User Info to our 'Products' User Info?

I hope this post is making sense, it's a bit difficult to explain...
0
WorknHardr
Asked:
WorknHardr
  • 2
1 Solution
 
Dale BurrellCommented:
Probably the easiest way to do it is store your db2 UserId in db1. This link explains how to add custom data to bd1 http://stackoverflow.com/questions/12435252/how-to-create-custom-additional-fields-in-userprofile-in-mvc4.

The tricky bit is creating both records either at the same time, or linking them (by email address maybe, but beware of security implications) later.

Once they are linked you can either access the db2 UserId you need directly from the user profile. Or you can store it in a session variable or similar to allow you easy access to it. Or course if you do this you need to take into account the situation when you session variables get purged.
0
 
WorknHardrAuthor Commented:
Works great, thx
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now