WindowsIdentity.GetCurrent メソッド

定義

現在のWindows ユーザーを表すWindowsIdentity オブジェクトを返します。

オーバーロード

名前 説明
GetCurrent(TokenAccessLevels)

指定した目的のトークン アクセス レベルを使用して、現在のWindows ユーザーを表すWindowsIdentity オブジェクトを返します。

GetCurrent(Boolean)

WindowsIdentity パラメーターの値に応じて、スレッドまたはプロセスのWindows ID を表すifImpersonating オブジェクトを返します。

GetCurrent()

現在のWindows ユーザーを表すWindowsIdentity オブジェクトを返します。

GetCurrent(TokenAccessLevels)

指定した目的のトークン アクセス レベルを使用して、現在のWindows ユーザーを表すWindowsIdentity オブジェクトを返します。

public:
 static System::Security::Principal::WindowsIdentity ^ GetCurrent(System::Security::Principal::TokenAccessLevels desiredAccess);
public static System.Security.Principal.WindowsIdentity GetCurrent(System.Security.Principal.TokenAccessLevels desiredAccess);
static member GetCurrent : System.Security.Principal.TokenAccessLevels -> System.Security.Principal.WindowsIdentity
Public Shared Function GetCurrent (desiredAccess As TokenAccessLevels) As WindowsIdentity

パラメーター

desiredAccess
TokenAccessLevels

列挙値のビットごとの組み合わせ。

返品

現在のユーザーを表すオブジェクト。

注釈

desiredAccess パラメーターは、アクセス トークンへの要求されたアクセスの種類を識別するアクセス マスクを指定します。 これらの要求されたアクセスの種類は、トークンの随意アクセス制御リスト (DACL) と比較して、許可または拒否されるアクセスの種類を決定します。

適用対象

GetCurrent(Boolean)

WindowsIdentity パラメーターの値に応じて、スレッドまたはプロセスのWindows ID を表すifImpersonating オブジェクトを返します。

public:
 static System::Security::Principal::WindowsIdentity ^ GetCurrent(bool ifImpersonating);
public static System.Security.Principal.WindowsIdentity? GetCurrent(bool ifImpersonating);
public static System.Security.Principal.WindowsIdentity GetCurrent(bool ifImpersonating);
static member GetCurrent : bool -> System.Security.Principal.WindowsIdentity
Public Shared Function GetCurrent (ifImpersonating As Boolean) As WindowsIdentity

パラメーター

ifImpersonating
Boolean

trueスレッドが現在偽装している場合にのみWindowsIdentityを返す場合はを返します。偽装している場合はスレッドのfalseを返し、スレッドが現在偽装していない場合はプロセスのWindowsIdentityを返WindowsIdentity

返品

Windows ユーザーを表すオブジェクト。

注釈

ifImpersonatingtrueされ、スレッドが偽装されていない場合、返されるWindowsIdentity オブジェクトには値がありません。 ifImpersonatingfalseされ、スレッドが偽装している場合は、スレッドのWindowsIdentityが返されます。 ifImpersonatingfalseされ、スレッドが偽装されていない場合は、プロセスのWindowsIdentityが返されます。

適用対象

GetCurrent()

現在のWindows ユーザーを表すWindowsIdentity オブジェクトを返します。

public:
 static System::Security::Principal::WindowsIdentity ^ GetCurrent();
public static System.Security.Principal.WindowsIdentity GetCurrent();
static member GetCurrent : unit -> System.Security.Principal.WindowsIdentity
Public Shared Function GetCurrent () As WindowsIdentity

返品

現在のユーザーを表すオブジェクト。

例外

呼び出し元に適切なアクセス許可がありません。

次のコードは、GetCurrent メソッドを使用して、現在のWindows ユーザーを表す WindowsIdentity オブジェクトを返す方法を示しています。 このコード例は、 WindowsIdentity クラスに提供されるより大きな例の一部です。

IntPtr accountToken = WindowsIdentity::GetCurrent()->Token;
IntPtr accountToken = WindowsIdentity.GetCurrent().Token;
Console.WriteLine( "Token number is: " + accountToken.ToString());
Dim accountToken As IntPtr = WindowsIdentity.GetCurrent().Token

適用対象