views:

746

answers:

3

Scenario: In an e-commerce system, a helpdesk user should be able to "impersonate" or "log on as" a specific customer (from the web-based administration site) so that he can support the customer first-hand - eg. when the Customer is on the phone.

Additional clarification: There is no need to keep track of the original authentication context. We simply need to provide a "Log on as" button that will log on as the customer without the helpdesk user needing to know the password.

Any ideas how this scenario could be implemented using regular ASP.NET Forms Authentication?

+2  A: 

Maybee I don't understand the scenario exactly. But why not let the support login as the user?

FormsAuthentication.SetAuthCookie("yourCustomersUserName");

Then it will be up to the e-commerce system to have an updated "cart" or whatever so the support can help..

ullmark
You could just take the username from a textbox that the support guy types in the username?
ullmark
Thanks, will try that!
JacobE
Does the session automatically switch when the auth cookie changes?
JacobE
A: 

I dont think this works

+1  A: 

I was able to get this to work, assuming you've got a user already logged in, you can impersonate another user with the below code.

FormsAuthentication.SignOut();

FormsAuthentication.SetAuthCookie("username", true );
Joel Tipke