是否有可能以模拟一个唯一的用户通过code在C#ASP.net Web应用程序的经验吗? [英] Is it possible to simulate the experience of a unique user through code in a c# ASP.net web application?

查看:126
本文介绍了是否有可能以模拟一个唯一的用户通过code在C#ASP.net Web应用程序的经验吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在IIS7运行的ASP.net Web应用程序。我们有多个用户,但我们并不总是知道他们的密码。下面是我们想怎么能够做到:

we have an ASP.net web application running on IIS7. We have multiple users, but we don't always know their password. Here's what we'd like to be able to do:

登录为某种管理员,与我们当前的用户列表psented $ P $,单击某种运行方式李四用户,我们就能够看到应用程序在该点(或某些网页)作为用户。

Login as some sort of administrator, be presented with our current list of users, click some sort of "Run as John Doe user", at which point we'd be able to see the application (or certain pages) as that user.

我们正在寻找这样做在一个支撑/调试的能力。我看着ASP.net的模拟,但这似乎并不适用于此。

We're looking to do this in a support/debugging capacity. I've looked into ASP.net's Impersonation, but that doesn't seem to apply here.

任何帮助/建议是AP preciated。如果我生活在一个梦幻世界,请让我知道。

Any help/advice is appreciated. If I'm living in a dream world, please let me know.

推荐答案

如果您正在使用的窗体身份验证所有你需要做的是发出一个身份验证Cookie与您试图冒充用户的用户名:

If you are using forms authentication all you need to do is to emit an authentication cookie with the username of the user you are trying to impersonate:

// Need to be signed as administrator in order to be
// able to impersonate
if (User.IsInRole("Administrator"))
{
    FormsAuthentication.SetAuthCookie("johndoe", false);
}

和下一个请求,你将李四。你也可以在会话中存储一些值,表明这是代表李四如果你需要这些信息的管理员。

and on the next request you will be John Doe. You could also store some value in the session to indicate that this is an administrator acting on behalf of John Doe if you ever needed this information.

如果您使用的是Windows NTLM身份验证我不认为这是可能的(请纠正我,如果我错了)。

If you are using Windows NTLM authentication I don't think this is possible (please correct me if I am wrong).

这篇关于是否有可能以模拟一个唯一的用户通过code在C#ASP.net Web应用程序的经验吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆