开发者

ASP.NET Authenticate as someone else

I am about to develop an ASP.NET MVC开发者_Go百科 3 site where there will be two different kinds of users: Global Administrator and Local Administrator.

A local administrator can administrate his own data. The global administrator can select a local administrator and sort-of "simulate" being that user. By this, I mean that he shoud preferably be able to see the same views etc.

What are your thoughts on how this behavior could be implemented?

Best Regards Kenneth


If you are using forms authentication you could impersonate any user:

[Authorize(Roles = "admin")]
public ActionResult BecomeGlobalAdmin()
{
    FormsAuthentication.SetAuthCookie("globaladmin", false);
    return RedirectToAction("index");
}

You might also want to store some information into the session which would indicate that the user is in fact an administrator but acting as a global administrator (if you need such functionality).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜