WindowsIdentity.GetCurrent メソッド
この記事の内容
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
現在の Windows ユーザーを表す WindowsIdentity オブジェクトを返します。
GetCurrent(TokenAccessLevels) |
目的のトークン アクセス レベルを指定して現在の Windows ユーザーを表す WindowsIdentity オブジェクトを返します。 |
GetCurrent(Boolean) |
|
GetCurrent() |
現在の Windows ユーザーを表す WindowsIdentity オブジェクトを返します。 |
目的のトークン アクセス レベルを指定して現在の 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) と比較して、許可または拒否されるアクセスの種類を決定します。
適用対象
.NET 9 およびその他のバージョン
製品 | バージョン |
---|---|
.NET | Core 1.0, Core 1.1, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 |
Windows Desktop | 3.0, 3.1, 5 |
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プロセスの が返されます。
適用対象
.NET 9 およびその他のバージョン
製品 | バージョン |
---|---|
.NET | Core 1.0, Core 1.1, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 |
Windows Desktop | 3.0, 3.1, 5 |
現在の 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
適用対象
.NET 9 およびその他のバージョン
製品 | バージョン |
---|---|
.NET | Core 1.0, Core 1.1, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 |
Windows Desktop | 3.0, 3.1, 5 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。