Solved

SimpleMembershipProvider UserID / Program Database UserID Translation Table?

Posted on 2013-11-04
3
328 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Why don't I see this table in EDMX file? 2 24
Problem to page 4 75
Error in page 3 46
Error in query expression 3 37
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,…
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

23 Experts available now in Live!

Get 1:1 Help Now