如何更改登录的用户到另一个? [英] How do I change the logged in user to another?

查看:178
本文介绍了如何更改登录的用户到另一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想改变登录的用户向其他用户暂时做一些处理。

I would like to change the logged in user to another user temporarily to do some process.

举例来说,假设我登录为乔。在我的方法,我想使登录用户从乔到超级用户,做了一些处理,然后更改登录的用户返回到乔。有人可以帮助呢?

For example, say I am logged in as "Joe". In my method, I want to make the logged in user from "Joe" to "SuperUser", do some process, then change the logged in user back to "Joe". Can someone help with this?

推荐答案

我想你想为ASP.NET模拟。请查看它是什么和的如何使用它。这样的事情(从第二个链接):

I think you want ASP.NET impersonation for that. Check out what it is and how to use it. Something like this (from the second link):

System.Security.Principal.WindowsImpersonationContext impersonationContext;
impersonationContext = ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();

//Insert your code that runs under the security context of the authenticating user here.

impersonationContext.Undo();

编辑:对于ASP.NET成员资格,请参见此等问题和<一HREF =HTTP://www.$c$cproject.com/KB/aspnet/FormsUserImpersonation.aspx相对=nofollow>这个答案

这篇关于如何更改登录的用户到另一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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