次の方法で共有


WindowsIdentity コンストラクタ (IntPtr, String, WindowsAccountType, Boolean)

指定した Windows アカウント トークン、指定した認証の種類、指定した Windows アカウントの種類、および指定した認証ステータスによって表されるユーザーを表す、WindowsIdentity クラスの新しいインスタンスを初期化します。

名前空間: System.Security.Principal
アセンブリ: mscorlib (mscorlib.dll 内)

構文

'宣言
Public Sub New ( _
    userToken As IntPtr, _
    type As String, _
    acctType As WindowsAccountType, _
    isAuthenticated As Boolean _
)
'使用
Dim userToken As IntPtr
Dim type As String
Dim acctType As WindowsAccountType
Dim isAuthenticated As Boolean

Dim instance As New WindowsIdentity(userToken, type, acctType, isAuthenticated)
public WindowsIdentity (
    IntPtr userToken,
    string type,
    WindowsAccountType acctType,
    bool isAuthenticated
)
public:
WindowsIdentity (
    IntPtr userToken, 
    String^ type, 
    WindowsAccountType acctType, 
    bool isAuthenticated
)
public WindowsIdentity (
    IntPtr userToken, 
    String type, 
    WindowsAccountType acctType, 
    boolean isAuthenticated
)
public function WindowsIdentity (
    userToken : IntPtr, 
    type : String, 
    acctType : WindowsAccountType, 
    isAuthenticated : boolean
)
適用できません。

パラメータ

  • userToken
    コードが実行されている対象ユーザーのアカウント トークン。
  • type
    ユーザーを識別するために使用する認証の種類。
  • isAuthenticated
    ユーザーが認証されていることを示す場合は true。それ以外の場合は false

例外

例外の種類 条件

ArgumentException

userToken が 0 です。

または

userToken は、複製され、偽装に対して無効になっています。

SecurityException

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

または

Win32 エラーが発生しました。

解説

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 isAuthenticated As Boolean = True
Dim windowsIdentity As New WindowsIdentity( _
    logonToken, authenticationType, guestAccount, isAuthenticated)
string authenticationType = "WindowsAuthentication";
WindowsAccountType guestAccount = WindowsAccountType.Guest;
bool isAuthenticated = true;
WindowsIdentity windowsIdentity = new WindowsIdentity(
    logonToken, authenticationType, guestAccount, isAuthenticated);
String^ authenticationType = "WindowsAuthentication";
WindowsAccountType guestAccount = WindowsAccountType::Guest;
bool isAuthenticated = true;
WindowsIdentity^ windowsIdentity = gcnew WindowsIdentity( logonToken,authenticationType,guestAccount,isAuthenticated );
String authenticationType = "WindowsAuthentication";
WindowsAccountType guestAccount = WindowsAccountType.Guest;
boolean isAuthenticated = true;
WindowsIdentity windowsIdentity = new WindowsIdentity(logonToken,
    authenticationType, guestAccount, isAuthenticated);

.NET Framework のセキュリティ

プラットフォーム

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 名前空間