如何模拟其他用户? [英] How to impersonate another user?

查看:247
本文介绍了如何模拟其他用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个ASP.net应用程序,我试图模拟用户

I'm working on an ASP.net app and i'm trying to impersonate a user

我创建一个带有的WindowsIdentity令牌

I'm creating a windowsIdentity with a token

WindowsIdentity winId = new WindowsIdenty( token );

此令牌是由调用未托管code得到了

this token was got by calling the un managed code

[DllImport("advapi32.dll")]
public static extern int LogonUserA(String lpszUserName, 
    String lpszDomain,
    String lpszPassword,
    int dwLogonType, 
    int dwLogonProvider,
    ref IntPtr phToken);

有没有其他的方式来获得一个令牌不使用此ADVAPI32.DLL非托管code?

is there any other way to get a token without using this advapi32.dll unmanaged code?

TKS

推荐答案

我个人preFER一个的包装类来处理这个模拟。

Personally, I prefer a wrapper class to handle this Impersonation.

所以,你会与非托管code一起工作,但据我所知是没有办法与管理$ C $做这个C直接。

So, you will be working with unmanaged code, but AFAIK there is no way to do this with managed code directly.

这篇关于如何模拟其他用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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