Share via


HostingEnvironment.Impersonate 方法

定義

允許程式碼模擬不同使用者。

多載

Impersonate()

模擬由應用程式識別所表示的使用者。

Impersonate(IntPtr)

模擬由指定使用者語彙基元所表示的使用者。

Impersonate(IntPtr, String)

模擬由指定虛擬路徑之組態設定所指定的使用者,或指定的使用者語彙基元。

Impersonate()

模擬由應用程式識別所表示的使用者。

public:
 static IDisposable ^ Impersonate();
public static IDisposable Impersonate ();
static member Impersonate : unit -> IDisposable
Public Shared Function Impersonate () As IDisposable

傳回

IDisposable

IDisposable 物件,表示模擬前的 Windows 使用者,這個物件可以用於還原為原始使用者的內容。

例外狀況

處理序無法模擬。

適用於

Impersonate(IntPtr)

模擬由指定使用者語彙基元所表示的使用者。

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

參數

token
IntPtr

nativeint

Windows 帳戶語彙基元的控制代碼。

傳回

IDisposable

IDisposable 物件,表示模擬前的 Windows 使用者,這個物件可以用於還原為原始使用者的內容。

例外狀況

處理序無法模擬。

適用於

Impersonate(IntPtr, String)

模擬由指定虛擬路徑之組態設定所指定的使用者,或指定的使用者語彙基元。

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

參數

userToken
IntPtr

nativeint

Windows 帳戶語彙基元的控制代碼。

virtualPath
String

要求之資源的路徑。

傳回

IDisposable

IDisposable 物件,表示模擬前的 Windows 使用者,這個物件可以用於還原為原始使用者的內容。

例外狀況

處理序無法模擬。

備註

方法 Impersonate 會在套用會影響指定虛擬路徑之組態設定中的所有元素之後,模擬結果的使用者。 identity如果未指定虛擬路徑的專案, Impersonate 方法就會模擬指定的Windows帳戶。

適用於