简体   繁体   中英

User impersonation with ASP.NET Forms Authentication

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?

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 );

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..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM