HostingEnvironment.Impersonate Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Allows code to impersonate a different user.
Overloads
Impersonate() |
Impersonates the user represented by the application identity. |
Impersonate(IntPtr) |
Impersonates the user represented by the specified user token. |
Impersonate(IntPtr, String) |
Impersonates the user specified by the configuration settings for the specified virtual path, or the specified user token. |
Impersonate()
Impersonates the user represented by the application identity.
public:
static IDisposable ^ Impersonate();
public static IDisposable Impersonate ();
static member Impersonate : unit -> IDisposable
Public Shared Function Impersonate () As IDisposable
Returns
An IDisposable object that represents the Windows user prior to impersonation; this object can be used to revert to the original user's context.
Exceptions
The process cannot impersonate.
Applies to
Impersonate(IntPtr)
Impersonates the user represented by the specified user token.
public:
static IDisposable ^ Impersonate(IntPtr token);
public static IDisposable Impersonate (IntPtr token);
static member Impersonate : nativeint -> IDisposable
Public Shared Function Impersonate (token As IntPtr) As IDisposable
Parameters
- token
-
IntPtr
nativeint
The handle of a Windows account token.
Returns
An IDisposable object that represents the Windows user prior to impersonation; this object can be used to revert to the original user's context.
Exceptions
The process cannot impersonate.
Applies to
Impersonate(IntPtr, String)
Impersonates the user specified by the configuration settings for the specified virtual path, or the specified user token.
public:
static IDisposable ^ Impersonate(IntPtr userToken, System::String ^ virtualPath);
public static IDisposable Impersonate (IntPtr userToken, string virtualPath);
static member Impersonate : nativeint * string -> IDisposable
Public Shared Function Impersonate (userToken As IntPtr, virtualPath As String) As IDisposable
Parameters
- userToken
-
IntPtr
nativeint
The handle of a Windows account token.
- virtualPath
- String
The path to the requested resource.
Returns
An IDisposable object that represents the Windows user prior to impersonation; this object can be used to revert to the original user's context.
Exceptions
The process cannot impersonate.
Remarks
The Impersonate method impersonates the user that results after applying all elements in the configuration settings affecting the specified virtual path. If an identity
element is not specified for the virtual path, the Impersonate method impersonates the specified Windows account.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기