HostingEnvironment.Impersonate HostingEnvironment.Impersonate HostingEnvironment.Impersonate HostingEnvironment.Impersonate Method

Definition

Allows code to impersonate a different user.

Overloads

Impersonate() Impersonate() Impersonate() Impersonate()

Impersonates the user represented by the application identity.

Impersonate(IntPtr) Impersonate(IntPtr) Impersonate(IntPtr) Impersonate(IntPtr)

Impersonates the user represented by the specified user token.

Impersonate(IntPtr, String) Impersonate(IntPtr, String) Impersonate(IntPtr, String) Impersonate(IntPtr, String)

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

Impersonate() Impersonate() Impersonate() 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.

Impersonate(IntPtr) Impersonate(IntPtr) Impersonate(IntPtr) 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 IntPtr IntPtr IntPtr

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.

Impersonate(IntPtr, String) Impersonate(IntPtr, String) Impersonate(IntPtr, String) 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 IntPtr IntPtr IntPtr

The handle of a Windows account token.

virtualPath
String String String 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