Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6918427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:51:27+00:00 2026-05-27T09:51:27+00:00

I’m currently implementing a website that require a customer support user to Login as

  • 0

I’m currently implementing a website that require a “customer support” user to Login as the customer itself for support purposes. The problem is that login with the customer user, interrupts the customer support login, so only a single user can be concurrently logged in from a single computer.

I use MVC3 with AspNetSqlMembershipProvider for authorization\authentication purposes.

How can I easly use multiple concurrent logins on a single computer?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:51:28+00:00Added an answer on May 27, 2026 at 9:51 am

    You should abstract this at a higher level than the authenticated user. I suggest that you introduce the concept of a logged in user and a current user. The session remains with the logged in user, but logged in users with sufficient privileges have the ability to impersonate other users, with that user becoming the current user. Use the current user to control access to data, drive the UI (with exceptions for what an impersonating user would need to control impersonation), perform transactions, etc. Store the current user in the session as data, perhaps setting commonly used properties on a base controller in OnActionExecuting as needed.

    public class AdminController : BaseController
    {
    
        [Authorize( Roles = "ActOnBehalfOfUser" )]
        [AcceptVerbs( HttpVerbs.Get )]
        public ActionResult Impersonate()
        {
            return View();
        }
    
        [Authorize( Roles = "ActOnBehalfOfUser" )]
        [AcceptVerbs( HttpVerbs.Post )]
        [ValidateAntiForgeryToken]
        public ActionResult Impersonate( string userNameOrID, bool? revoke )
        {
            var currentUser = this.GetCurrentUser();
    
            if (revoke.HasValue && revoke.Value)
            {
                try
                {
                    LogImpersonationEnd( currentUser );
                }
                catch { }
                this.SetEffectiveUser( currentUser );
            }
            else
            {
                if (string.IsNullOrEmpty( userNameOrID ))
                {
                    this.ModelState.AddModelError( "userNameOrID", "You must supply a username or uid to impersonate." );
                    return View();
                }
    
                var person = this.LookupUser( userNameOrID );
                if (person == null)
                {
                    this.ModelState.AddModelError( "userNameOrID", "No user with the given id was found." );
                    return View();
                }
    
                this.SetEffectiveUser( person );
                try
                {
                    using (var dc = new FooDataContext())
                    {
                        var impersonation = new Impersonation
                        {
                            EffectiveUser = person.UID,
                            ActualUser = currentUser.UID
                        };
                        dc.InsertOnSubmit( impersonation );
                        dc.SubmitChanges();
                    }
                }
                catch { }
            }
    
            return View();
    
        }
    }
    

    Base Controller:

    public class BaseController : Controller
    {
        protected bool IsImpersonating
        {
            get
            {
                var effectiveUID = this.Session[EFFECTIVE_USER_KEY] as string;
                var uid = this.Session[USER_KEY] as string;
                return !string.Equals( effectiveUID, uid );
            }
        }
    
        protected Person GetEffectiveUser()
        {
            return GetUser( this.Session[EFFECTIVE_USER_KEY] as string );
        }
    
        protected void SetEffectiveUser( Person person )
        {
            this.Session[EFFECTIVE_USER_KEY] = person.UniversityID;
            this.Session[UIPERSON_KEY + person.UniversityID] = person;
        }
    
        protected Person GetUser( string uid )
        {
            Person person = null;
            if (!string.IsNullOrEmpty( uid ))
            {
                person= GetCachedPerson( uid, p => p.UID == uid );
            }
            return person ?? new AnonymousPerson();
        }
    
    
    
        protected Person LookupUser( string usernameOrUID )
        {
            Person person = null;
            if (!string.IsNullOrEmpty( usernameOrUID ))
            {
                uiPerson = this.GetCachedPerson( usernameOrUID, p => p.UID== usernameOrUID || p.Username == usernameOrUID );
            }
            return uiPerson;
        }
    
        private Person GetCachedPerson( string uid, Expression<Func<Person, bool>> selector )
        {
            Person person = this.Session[PERSON_KEY + uid] as Person;
            if (person == null)
            {
                using (var context = new FooDataContext())
                {
                    person = context.SingleOrDefault<Person>( selector );
                    if (uiPerson != null)
                    {
                        this.Session[PERSON_KEY + uid] = person;
                    }
                }
            }
            return person;
        }
    
        protected void LogImpersonationEnd( Person currentUser )
        {
            using (var dc = new FooDataContext())
            {
                var euid = this.GetEffectiveUser().UID;
                var impersonation = dc.Table<Impersonation>()
                                      .Where( i => i.EffectiveUser == euid && i.ActualUser == currentUser.UniversityID && !i.EndTime.HasValue )
                                      .OrderByDescending( i => i.ID )
                                      .FirstOrDefault();
    
                if (impersonation != null)
                {
                    impersonation.EndTime = DateTime.Now;
                    dc.SubmitChanges();
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I need to clean up various Word 'smart' characters in user input, including but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.