指定した Windows アカウント トークン、指定した認証の種類、および指定した Windows アカウントの種類によって表されるユーザーを表す、WindowsIdentity クラスの新しいインスタンスを初期化します。
名前空間: System.Security.Principal
アセンブリ: mscorlib (mscorlib.dll 内)
構文
'宣言
Public Sub New ( _
userToken As IntPtr, _
type As String, _
acctType As WindowsAccountType _
)
'使用
Dim userToken As IntPtr
Dim type As String
Dim acctType As WindowsAccountType
Dim instance As New WindowsIdentity(userToken, type, acctType)
public WindowsIdentity (
IntPtr userToken,
string type,
WindowsAccountType acctType
)
public:
WindowsIdentity (
IntPtr userToken,
String^ type,
WindowsAccountType acctType
)
public WindowsIdentity (
IntPtr userToken,
String type,
WindowsAccountType acctType
)
public function WindowsIdentity (
userToken : IntPtr,
type : String,
acctType : WindowsAccountType
)
適用できません。
パラメータ
- userToken
コードが実行されている対象ユーザーのアカウント トークン。
- type
ユーザーを識別するために使用する認証の種類。
- acctType
WindowsAccountType 値の 1 つ。
例外
例外の種類 | 条件 |
---|---|
userToken が 0 です。 または userToken は、複製され、偽装に対して無効になっています。 |
|
呼び出し元に、正しいアクセス許可がありません。 または Win32 エラーが発生しました。 |
解説
WindowsIdentity のインスタンスの初期プロパティ値を次の表に示します。
プロパティ |
初期値 |
---|---|
false |
![]() |
---|
userToken で表されるトークンは、Win32 API の LogonUser 関数などのアンマネージ コードを呼び出すことで取得できます。userToken は、常に Win32 API の Close 関数を呼び出して解放してください。アンマネージ コードの呼び出しの詳細については、「アンマネージ DLL 関数の処理」を参照してください。 |
使用例
WindowsIdentity コンストラクタを使用し、指定した Windows アカウント トークン、指定した認証タイプ、および指定した Windows アカウント タイプで表されるユーザーを表す WindowsIdentity クラスの新しいインスタンスを作成するコード例を次に示します。このコード例は、WindowsIdentity クラスのトピックで取り上げているコード例の一部分です。
Dim authenticationType As String = "WindowsAuthentication"
Dim guestAccount As WindowsAccountType = WindowsAccountType.Guest
Dim windowsIdentity As _
New WindowsIdentity(logonToken, authenticationType, guestAccount)
string authenticationType = "WindowsAuthentication";
WindowsAccountType guestAccount = WindowsAccountType.Guest;
WindowsIdentity windowsIdentity =
new WindowsIdentity(logonToken, authenticationType, guestAccount);
String^ authenticationType = "WindowsAuthentication";
WindowsAccountType guestAccount = WindowsAccountType::Guest;
WindowsIdentity^ windowsIdentity = gcnew WindowsIdentity( logonToken,authenticationType,guestAccount );
String authenticationType = "WindowsAuthentication";
WindowsAccountType guestAccount = WindowsAccountType.Guest;
WindowsIdentity windowsIdentity = new WindowsIdentity(logonToken,
authenticationType, guestAccount);
.NET Framework のセキュリティ
- SecurityPermission (プリンシパル オブジェクトを操作するために必要なアクセス許可)。SecurityPermissionFlag.ControlPrincipal (関連する列挙体)。
- SecurityPermission (アンマネージ コードにアクセスするために必要なアクセス許可)。SecurityPermissionFlag.UnmanagedCode (関連する列挙体)
プラットフォーム
Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition
Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。
バージョン情報
.NET Framework
サポート対象 : 3.0,2.0,1.1,1.0
参照
関連項目
WindowsIdentity クラス
WindowsIdentity メンバ
System.Security.Principal 名前空間