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

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

戻り値

WindowsIdentity

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

注釈

パラメーター 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

戻り値

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

戻り値

WindowsIdentity

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

例外

呼び出し元に、正しいアクセス許可がありません。

次のコードは、 メソッドを使用して、現在のユーザーを表す オブジェクト GetCurrent WindowsIdentity をWindowsしています。 このコード例は、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

適用対象