概述
.NET模拟方法
名称空间提供了几个模拟API。首选方法是:System.Security.Principal
>同步假冒:WindowsIdentity.RunImpersonated
WindowsIdentity.RunImpersonated(userHandle, () => { /* Impersonated code here */ });
提供了一种用于处理长期运行操作的异步对应物。>
WindowsIdentity.RunImpersonatedAsync
await WindowsIdentity.RunImpersonatedAsync(userHandle, async () => { /* Impersonated code here */ });
>LogonUser
重要说明:
using SimpleImpersonation; var credentials = new UserCredentials(domain, username, password); using SafeAccessTokenHandle userHandle = credentials.LogonUser(LogonType.Interactive);
>远程资源访问:密钥要求
LogonUser
模拟在本地机器上运行。 访问远程资源需要:
>域成员或信任:
以上是我如何在.NET中冒充用户并访问远程资源?的详细内容。更多信息请关注PHP中文网其他相关文章!