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

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

GenericPrincipal コンストラクタ

ユーザー ID と、その ID が表すユーザー属しているロールの名前の配列から、GenericPrincipal クラス新しインスタンス初期化します。

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

Public Sub New ( _
    identity As IIdentity, _
    roles As String() _
)
Dim identity As IIdentity
Dim roles As String()

Dim instance As New GenericPrincipal(identity,
 roles)
public GenericPrincipal (
    IIdentity identity,
    string[] roles
)
public:
GenericPrincipal (
    IIdentity^ identity, 
    array<String^>^ roles
)
public GenericPrincipal (
    IIdentity identity, 
    String[] roles
)
public function GenericPrincipal (
    identity : IIdentity, 
    roles : String[]
)

パラメータ

identity

任意のユーザーを表す IIdentity の基本実装

roles

identity パラメータによって表されるユーザー属しているロールの名前の配列

例外例外
例外種類条件

ArgumentNullException

identity パラメータnull 参照 (Visual Basic では Nothing) です。

使用例使用例

GenericPrincipal コンストラクタ使用する方法次のコード示します。このコード例は、GenericPrincipal クラストピック取り上げているコード例一部分です。

Dim roles(10) As String
Dim windowsIdentity As WindowsIdentity = windowsIdentity.GetCurrent()

If (windowsIdentity.IsAuthenticated) Then
    ' Add custom NetworkUser role.
    roles(0) = "NetworkUser"
End If

If (windowsIdentity.IsGuest) Then
    ' Add custom GuestUser role.
    roles(1) = "GuestUser"
End If


If (windowsIdentity.IsSystem) Then
    ' Add custom SystemUser role.
    roles(2) = "SystemUser"
End If

' Construct a GenericIdentity object based on the current Windows
' identity name and authentication type.
Dim authenticationType As String
 = windowsIdentity.AuthenticationType
Dim userName As String =
 windowsIdentity.Name
Dim genericIdentity = _
    New GenericIdentity(userName, authenticationType)

' Construct a GenericPrincipal object based on the generic identity
' and custom roles for the user.
Dim genericPrincipal As New
 GenericPrincipal(genericIdentity, roles)
WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent();
string[] roles = new string[10];
if (windowsIdentity.IsAuthenticated)
{
    // Add custom NetworkUser role.
    roles[0] = "NetworkUser";
}

if (windowsIdentity.IsGuest)
{
    // Add custom GuestUser role.
    roles[1] = "GuestUser";
}

if (windowsIdentity.IsSystem)
{
    // Add custom SystemUser role.
    roles[2] = "SystemUser";
}

// Construct a GenericIdentity object based on the current Windows
// identity name and authentication type.
string authenticationType = windowsIdentity.AuthenticationType;
string userName = windowsIdentity.Name;
GenericIdentity genericIdentity =
    new GenericIdentity(userName, authenticationType);

// Construct a GenericPrincipal object based on the generic identity
// and custom roles for the user.
GenericPrincipal genericPrincipal =
    new GenericPrincipal(genericIdentity, roles);
WindowsIdentity^ windowsIdentity = WindowsIdentity::GetCurrent();
array<String^>^roles = gcnew array<String^>(10);
if ( windowsIdentity->IsAuthenticated )
{
   
   // Add custom NetworkUser role.
   roles[ 0 ] = L"NetworkUser";
}

if ( windowsIdentity->IsGuest )
{
   
   // Add custom GuestUser role.
   roles[ 1 ] = L"GuestUser";
}

if ( windowsIdentity->IsSystem )
{
   
   // Add custom SystemUser role.
   roles[ 2 ] = L"SystemUser";
}

// Construct a GenericIdentity object based on the current Windows
// identity name and authentication type.
String^ authenticationType = windowsIdentity->AuthenticationType;
String^ userName = windowsIdentity->Name;
GenericIdentity^ genericIdentity = gcnew GenericIdentity(
   userName,authenticationType );

// Construct a GenericPrincipal object based on the generic identity
// and custom roles for the user.
GenericPrincipal^ genericPrincipal = gcnew GenericPrincipal(
   genericIdentity,roles );
WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent();
String roles[] = new String[10];
if (windowsIdentity.get_IsAuthenticated()) {
    // Add custom NetworkUser role.
    roles.set_Item(0, "NetworkUser");
}

if (windowsIdentity.get_IsGuest()) {
    // Add custom GuestUser role.
    roles.set_Item(1, "GuestUser");
}

if (windowsIdentity.get_IsSystem()) {
    // Add custom SystemUser role.
    roles.set_Item(2, "SystemUser");
}
// Construct a GenericIdentity object based on the current Windows
// identity name and authentication type.
String authenticationType = windowsIdentity.get_AuthenticationType();
String userName = windowsIdentity.get_Name();
GenericIdentity genericIdentity = new GenericIdentity(userName,
 
    authenticationType);
// Construct a GenericPrincipal object based on the generic identity
// and custom roles for the user.
GenericPrincipal genericPrincipal = new GenericPrincipal(genericIdentity
,
    roles);
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
GenericPrincipal クラス
GenericPrincipal メンバ
System.Security.Principal 名前空間



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

辞書ショートカット

すべての辞書の索引

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

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

   

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



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

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

©2024 GRAS Group, Inc.RSS