你如何在 .NET 中进行模拟? [英] How do you do Impersonation in .NET?

查看:30
本文介绍了你如何在 .NET 中进行模拟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 .NET 中是否有一种开箱即用的简单方法来模拟用户?

Is there a simple out of the box way to impersonate a user in .NET?

到目前为止,我一直在使用 代码项目中的这个类我的模拟要求.

So far I've been using this class from code project for all my impersonation requirements.

使用 .NET Framework 有没有更好的方法来做到这一点?

Is there a better way to do it by using .NET Framework?

我有一个用户凭据集(用户名、密码、域名),它代表我需要模拟的身份.

I have a user credential set, (username, password, domain name) which represents the identity I need to impersonate.

推荐答案

这里是 .NET 模拟概念的一些很好的概述.

Here is some good overview of .NET impersonation concepts.

基本上,您将利用这些在 .NET 框架中开箱即用的类:

Basically you will be leveraging these classes that are out of the box in the .NET framework:

代码通常会变得冗长,这就是为什么您会看到许多示例,例如您引用的示例,试图简化流程.

The code can often get lengthy though and that is why you see many examples like the one you reference that try to simplify the process.

这篇关于你如何在 .NET 中进行模拟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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