How do you do Impersonation in .NET?

前端 未结 7 2250
情话喂你
情话喂你 2020-11-21 07:01

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.

7条回答
  •  情书的邮戳
    2020-11-21 08:00

    Here is some good overview of .NET impersonation concepts.

    • Michiel van Otegem: WindowsImpersonationContext made easy
    • WindowsIdentity.Impersonate Method (check out the code samples)

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

    • WindowsImpersonationContext
    • WindowsIdentity

    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.

提交回复
热议问题