Solved

SimpleMembershipProvider UserID / Program Database UserID Translation Table?

Posted on 2013-11-04
3
327 Views
Last Modified: 2013-11-06
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
Comment
Question by:WorknHardr
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
Dale Burrell earned 500 total points
ID: 39623249
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
 

Author Comment

by:WorknHardr
ID: 39624166
0
 

Author Closing Comment

by:WorknHardr
ID: 39628064
Works great, thx
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now