如何更改登录的用户到另一个?

编程入门 行业动态 更新时间:2024-10-28 00:23:58
本文介绍了如何更改登录的用户到另一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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成员资格,请参见此等问题和这个答案

更多推荐

如何更改登录的用户到另一个?

本文发布于:2023-11-11 11:48:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1578354.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何更改   用户

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!