WindowsIdentity コンストラクタとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > WindowsIdentity コンストラクタの意味・解説 

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

指定した UPN (User Principal Name) と指定した認証種類表されるユーザーを表す WindowsIdentity クラス新しインスタンス初期化します。

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

Public Sub New ( _
    sUserPrincipalName As String, _
    type As String _
)
Dim sUserPrincipalName As String
Dim type As String

Dim instance As New WindowsIdentity(sUserPrincipalName,
 type)
public WindowsIdentity (
    string sUserPrincipalName,
    string type
)
public:
WindowsIdentity (
    String^ sUserPrincipalName, 
    String^ type
)
public WindowsIdentity (
    String sUserPrincipalName, 
    String type
)
public function WindowsIdentity (
    sUserPrincipalName : String, 
    type : String
)

パラメータ

sUserPrincipalName

コード実行されている対象ユーザーUPN

type

ユーザー識別するために使用する認証種類

例外例外
例外種類条件

UnauthorizedAccessException

Windows は、Windows NT ステータス コード STATUS_ACCESS_DENIED を返しました

OutOfMemoryException

使用できるメモリ不足してます。

SecurityException

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

解説解説
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WindowsIdentity クラス
WindowsIdentity メンバ
System.Security.Principal 名前空間

WindowsIdentity コンストラクタ (IntPtr)

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

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

Public Sub New ( _
    userToken As IntPtr _
)
Dim userToken As IntPtr

Dim instance As New WindowsIdentity(userToken)
public WindowsIdentity (
    IntPtr userToken
)
public:
WindowsIdentity (
    IntPtr userToken
)
public WindowsIdentity (
    IntPtr userToken
)
public function WindowsIdentity (
    userToken : IntPtr
)

パラメータ

userToken

コード実行されている対象ユーザーアカウント トークン

例外例外
例外種類条件

ArgumentException

userToken が 0 です。

または

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

SecurityException

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

または

Win32 エラー発生しました

解説解説

WindowsIdentityインスタンス初期プロパティ値を次の表に示します

プロパティ

初期値

AuthenticationType

NTLM

WindowsAccountType

Normal

IsAuthenticated

false

使用例使用例

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());
    }
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WindowsIdentity クラス
WindowsIdentity メンバ
System.Security.Principal 名前空間

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

ユーザー識別するために使用する認証種類

acctType

WindowsAccountType 値の 1 つ

isAuthenticated

ユーザー認証されていることを示す場合trueそれ以外場合false

例外例外
例外種類条件

ArgumentException

userToken が 0 です。

または

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

SecurityException

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

または

Win32 エラー発生しました

解説解説
使用例使用例

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 のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WindowsIdentity クラス
WindowsIdentity メンバ
System.Security.Principal 名前空間

WindowsIdentity コンストラクタ (SerializationInfo, StreamingContext)

SerializationInfo ストリーム内の情報表されるユーザーを表す WindowsIdentity クラス新しインスタンス初期化します。

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

Public Sub New ( _
    info As SerializationInfo, _
    context As StreamingContext _
)
Dim info As SerializationInfo
Dim context As StreamingContext

Dim instance As New WindowsIdentity(info,
 context)
public WindowsIdentity (
    SerializationInfo info,
    StreamingContext context
)
public:
WindowsIdentity (
    SerializationInfo^ info, 
    StreamingContext context
)
public WindowsIdentity (
    SerializationInfo info, 
    StreamingContext context
)
public function WindowsIdentity (
    info : SerializationInfo, 
    context : StreamingContext
)

パラメータ

info

ユーザーアカウント情報格納する SerializationInfo。

context

ストリーム特性を示す StreamingContext。

例外例外
例外種類条件

NotSupportedException

WindowsIdentityプロセス間でシリアル化することはできません。

SecurityException

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

または

Win32 エラー発生しました

.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WindowsIdentity クラス
WindowsIdentity メンバ
System.Security.Principal 名前空間

WindowsIdentity コンストラクタ

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 クラス
WindowsIdentity メンバ
System.Security.Principal 名前空間

WindowsIdentity コンストラクタ (String)

指定した UPN (User Principal Name) で表されるユーザーを表す WindowsIdentity クラス新しインスタンス初期化します。

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

Public Sub New ( _
    sUserPrincipalName As String _
)
Dim sUserPrincipalName As String

Dim instance As New WindowsIdentity(sUserPrincipalName)
public WindowsIdentity (
    string sUserPrincipalName
)
public:
WindowsIdentity (
    String^ sUserPrincipalName
)
public WindowsIdentity (
    String sUserPrincipalName
)
public function WindowsIdentity (
    sUserPrincipalName : String
)

パラメータ

sUserPrincipalName

コード実行されている対象ユーザーUPN

例外例外
例外種類条件

UnauthorizedAccessException

Windows は、Windows NT ステータス コード STATUS_ACCESS_DENIED を返しました

OutOfMemoryException

使用できるメモリ不足してます。

SecurityException

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

解説解説
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WindowsIdentity クラス
WindowsIdentity メンバ
System.Security.Principal 名前空間

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

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

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

Public Sub New ( _
    userToken As IntPtr, _
    type As String _
)
Dim userToken As IntPtr
Dim type As String

Dim instance As New WindowsIdentity(userToken,
 type)
public WindowsIdentity (
    IntPtr userToken,
    string type
)
public:
WindowsIdentity (
    IntPtr userToken, 
    String^ type
)
public WindowsIdentity (
    IntPtr userToken, 
    String type
)
public function WindowsIdentity (
    userToken : IntPtr, 
    type : String
)

パラメータ

userToken

コード実行されている対象ユーザーアカウント トークン

type

ユーザー識別するために使用する認証種類

例外例外
例外種類条件

ArgumentException

userToken が 0 です。

または

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

SecurityException

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

または

Win32 エラー発生しました

解説解説
使用例使用例

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

String authenticationType = "WindowsAuthentication";
WindowsIdentity windowsIdentity =
    new WindowsIdentity(logonToken, authenticationType);
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WindowsIdentity クラス
WindowsIdentity メンバ
System.Security.Principal 名前空間

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

指定した 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 つ

例外例外
例外種類条件

ArgumentException

userToken が 0 です。

または

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

SecurityException

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

または

Win32 エラー発生しました

解説解説
使用例使用例

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 のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
WindowsIdentity クラス
WindowsIdentity メンバ
System.Security.Principal 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「WindowsIdentity コンストラクタ」の関連用語

WindowsIdentity コンストラクタのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



WindowsIdentity コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS