Impersonates the user specified by the configuration settings for the specified virtual path, or the specified user token.
![]()
An IDisposable object that represents the Windows user prior to impersonation; this object can be used to revert to the original user's context.
The HostingEnvironment.Impersonate(IntPtr, string) method impersonates the user that results after applying all identity elements in the configuration settings affecting the specified virtual path. If an identity element is not specified for the virtual path, the HostingEnvironment.Impersonate(IntPtr, string) method impersonates the specified Windows account.