Share via


WindowsIdentity.GetCurrent メソッド

定義

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

オーバーロード

GetCurrent(TokenAccessLevels)

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

GetCurrent(Boolean)

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

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)

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

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

スレッドが現在偽装中の場合にだけ WindowsIdentity を返すには、true。スレッドが偽装中の場合にスレッドの WindowsIdentity を返すか、またはスレッドが現在偽装中でない場合にプロセスの WindowsIdentity を返すには、false

戻り値

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

注釈

true で、スレッドが偽装されていない場合ifImpersonating、返されるWindowsIdentityオブジェクトには値がありません。 が false で、スレッドが偽装している場合ifImpersonatingは、WindowsIdentityスレッドの が返されます。 が false で、スレッドが偽装していない場合ifImpersonatingは、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

適用対象