WindowsIdentity コンストラクタ (String, String)
アセンブリ: mscorlib (mscorlib.dll 内)

Dim sUserPrincipalName As String Dim type As String Dim instance As New WindowsIdentity(sUserPrincipalName, type)


sUserPrincipalName が示す UPN は、そのユーザーのトークンを Win32 API の LsaLogonUser 関数の呼び出しによって取得するために使用されます。つまり、トークンはユーザーを識別するために使用されます。与えられた UPN を使用してログオンできないために、例外が返される場合もあります。
![]() |
---|
このコンストラクタは、Windows Server 2003 ドメインに参加しているコンピュータでの使用を想定しています。その他のドメイン タイプでは、例外がスローされます。 |

- SecurityPermission (プリンシパル オブジェクトを操作するために必要なアクセス許可)。SecurityPermissionFlag.ControlPrincipal (関連する列挙体)
- SecurityPermission (アンマネージ コードにアクセスするために必要なアクセス許可)。SecurityPermissionFlag.UnmanagedCode (関連する列挙体)

Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


WindowsIdentity コンストラクタ (IntPtr)
アセンブリ: mscorlib (mscorlib.dll 内)




WindowsIdentity コンストラクタを使用し、現在の Windows アカウント トークンで表されるユーザーを表す WindowsIdentity クラスの新しいインスタンスを作成するコード例を次に示します。WindowsIdentity オブジェクトは、トークン所有者のセキュリティ識別子、および現在のユーザーが属しているグループの ID 参照を取得する場合に使用します。
Imports System Imports System.Security.Principal Class WindowsIdentityMembers <STAThread()> _ Shared Sub Main(ByVal args() As String) Dim accountToken As IntPtr accountToken = WindowsIdentity.GetCurrent().Token Dim windowsIdentity1 As New WindowsIdentity(accountToken) Dim si As SecurityIdentifier = windowsIdentity1.Owner Console.WriteLine(si.ToString()) si = windowsIdentity1.User Console.WriteLine(si.ToString()) Dim irc As IdentityReferenceCollection = windowsIdentity1.Groups Dim ir As IdentityReference For Each ir In irc Console.WriteLine(ir.Value) Next ir Dim token As TokenImpersonationLevel = windowsIdentity1.ImpersonationLevel Console.WriteLine(token.ToString()) End Sub 'Main End Class 'WindowsIdentityMembers
using System; using System.Security.Principal; class WindowsIdentityMembers { [STAThread] static void Main(string[] args) { IntPtr accountToken = WindowsIdentity.GetCurrent().Token; WindowsIdentity windowsIdentity = new WindowsIdentity(accountToken); SecurityIdentifier si = windowsIdentity.Owner; Console.WriteLine(si.ToString()); si = windowsIdentity.User; Console.WriteLine(si.ToString()); IdentityReferenceCollection irc = windowsIdentity.Groups; foreach (IdentityReference ir in irc) { Console.WriteLine(ir.Value); } TokenImpersonationLevel token = windowsIdentity.ImpersonationLevel; Console.WriteLine(token.ToString()); } }

- SecurityPermission (プリンシパル オブジェクトを操作するために必要なアクセス許可)。SecurityPermissionFlag.ControlPrincipal (関連する列挙体)
- SecurityPermission (アンマネージ コードにアクセスするために必要なアクセス許可)。SecurityPermissionFlag.UnmanagedCode (関連する列挙体)

Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


WindowsIdentity コンストラクタ (IntPtr, String, WindowsAccountType, Boolean)
アセンブリ: 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 )
- acctType
WindowsAccountType 値の 1 つ。


通常、userToken で表されるトークンは、Win32 API の LogonUser 関数の呼び出しなど、アンマネージ コードの呼び出しによって取得します。アンマネージ コードの呼び出しの詳細については、「アンマネージ 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);

- SecurityPermission (プリンシパル オブジェクトを操作するために必要なアクセス許可)。SecurityPermissionFlag.ControlPrincipal (関連する列挙体)
- SecurityPermission (アンマネージ コードにアクセスするために必要なアクセス許可)。SecurityPermissionFlag.UnmanagedCode (関連する列挙体)

Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


WindowsIdentity コンストラクタ (SerializationInfo, StreamingContext)
アセンブリ: mscorlib (mscorlib.dll 内)

Dim info As SerializationInfo Dim context As StreamingContext Dim instance As New WindowsIdentity(info, context)



Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


WindowsIdentity コンストラクタ

名前 | 説明 |
---|---|
WindowsIdentity (IntPtr) | 指定した Windows アカウント トークンによって表されるユーザーを表す、WindowsIdentity クラスの新しいインスタンスを初期化します。 |
WindowsIdentity (String) | 指定した UPN (User Principal Name) で表されるユーザーを表す WindowsIdentity クラスの新しいインスタンスを初期化します。 |
WindowsIdentity (IntPtr, String) | 指定した Windows アカウント トークンと指定した認証の種類によって表されるユーザーを表す、WindowsIdentity クラスの新しいインスタンスを初期化します。 |
WindowsIdentity (SerializationInfo, StreamingContext) | SerializationInfo ストリーム内の情報で表されるユーザーを表す WindowsIdentity クラスの新しいインスタンスを初期化します。 |
WindowsIdentity (String, String) | 指定した UPN (User Principal Name) と指定した認証の種類で表されるユーザーを表す WindowsIdentity クラスの新しいインスタンスを初期化します。 |
WindowsIdentity (IntPtr, String, WindowsAccountType) | 指定した Windows アカウント トークン、指定した認証の種類、および指定した Windows アカウントの種類によって表されるユーザーを表す、WindowsIdentity クラスの新しいインスタンスを初期化します。 |
WindowsIdentity (IntPtr, String, WindowsAccountType, Boolean) | 指定した Windows アカウント トークン、指定した認証の種類、指定した Windows アカウントの種類、および指定した認証ステータスによって表されるユーザーを表す、WindowsIdentity クラスの新しいインスタンスを初期化します。 |

WindowsIdentity コンストラクタ (String)
アセンブリ: mscorlib (mscorlib.dll 内)



sUserPrincipalName が示す UPN は、そのユーザーのトークンを Win32 API の LsaLogonUser 関数の呼び出しによって取得するために使用されます。つまり、トークンはユーザーを識別するために使用されます。与えられた UPN を使用してログオンできないために、例外が返される場合もあります。
![]() |
---|
このコンストラクタは、Windows Server 2003 ドメインだけに参加しているコンピュータでの使用を想定しています。その他のドメイン タイプでは、例外がスローされます。 |

- SecurityPermission (プリンシパル オブジェクトを操作するために必要なアクセス許可)。SecurityPermissionFlag.ControlPrincipal (関連する列挙体)
- SecurityPermission (アンマネージ コードにアクセスするために必要なアクセス許可)。SecurityPermissionFlag.UnmanagedCode (関連する列挙体)

Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


WindowsIdentity コンストラクタ (IntPtr, String)
アセンブリ: mscorlib (mscorlib.dll 内)




WindowsIdentity コンストラクタを使用し、指定した Windows アカウント トークンおよび指定した認証タイプで表されるユーザーを表す WindowsIdentity クラスの新しいインスタンスを作成するコード例を次に示します。このコード例は、WindowsIdentity クラスのトピックで取り上げているコード例の一部分です。
Dim authenticationType = "WindowsAuthentication" Dim windowsIdentity As _ New WindowsIdentity(logonToken, authenticationType)
string authenticationType = "WindowsAuthentication"; WindowsIdentity windowsIdentity = new WindowsIdentity(logonToken, authenticationType);
String^ authenticationType = "WindowsAuthentication"; WindowsIdentity^ windowsIdentity = gcnew WindowsIdentity( logonToken,authenticationType );

- SecurityPermission (プリンシパル オブジェクトを操作するために必要なアクセス許可)。SecurityPermissionFlag.ControlPrincipal (関連する列挙体)
- SecurityPermission (アンマネージ コードにアクセスするために必要なアクセス許可)。SecurityPermissionFlag.UnmanagedCode (関連する列挙体)

Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


WindowsIdentity コンストラクタ (IntPtr, String, WindowsAccountType)
アセンブリ: mscorlib (mscorlib.dll 内)

Dim userToken As IntPtr Dim type As String Dim acctType As WindowsAccountType Dim instance As New WindowsIdentity(userToken, type, acctType)
public function WindowsIdentity ( userToken : IntPtr, type : String, acctType : WindowsAccountType )
- acctType
WindowsAccountType 値の 1 つ。



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);

- SecurityPermission (プリンシパル オブジェクトを操作するために必要なアクセス許可)。SecurityPermissionFlag.ControlPrincipal (関連する列挙体)
- SecurityPermission (アンマネージ コードにアクセスするために必要なアクセス許可)。SecurityPermissionFlag.UnmanagedCode (関連する列挙体)

Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- WindowsIdentity コンストラクタのページへのリンク