Solved

SimpleMembershipProvider UserID / Program Database UserID Translation Table?

Posted on 2013-11-04
3
331 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project

736 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