System.Web.Hosting.HostingEnvironment.Impersonate Method

Impersonates the user specified by the configuration settings for the specified virtual path, or the specified user token.

Syntax

public static IDisposable Impersonate (IntPtr userToken, string virtualPath)

Parameters

userToken
The handle of a Windows account token.
virtualPath
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.

Remarks

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.

Requirements

Namespace: System.Web.Hosting
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0