WindowsBuiltInRole 列挙型

定義

IsInRole(String)で使用する共通ロールを指定します。

public enum class WindowsBuiltInRole
public enum WindowsBuiltInRole
[System.Serializable]
public enum WindowsBuiltInRole
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum WindowsBuiltInRole
type WindowsBuiltInRole = 
[<System.Serializable>]
type WindowsBuiltInRole = 
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type WindowsBuiltInRole = 
Public Enum WindowsBuiltInRole
継承
WindowsBuiltInRole
属性

フィールド

名前 説明
Administrator 544

管理者は、コンピューターまたはドメインに完全かつ無制限にアクセスできます。

User 545

ユーザーは、システム全体で偶発的または意図的な変更を行うことを防ぎます。 そのため、ユーザーは認定アプリケーションを実行できますが、ほとんどのレガシ アプリケーションは実行できません。

Guest 546

ゲストはユーザーよりも制限されます。

PowerUser 547

パワー ユーザーは、いくつかの制限を持つほとんどの管理アクセス許可を持っています。 そのため、パワー ユーザーは、認定されたアプリケーションに加えて、レガシ アプリケーションを実行できます。

AccountOperator 548

アカウントオペレーターは、コンピューターまたはドメインのユーザー アカウントを管理します。

SystemOperator 549

システムオペレーターは、特定のコンピューターを管理します。

PrintOperator 550

印刷オペレーターは、プリンターを制御できます。

BackupOperator 551

バックアップオペレーターは、ファイルのバックアップまたは復元のみを目的として、セキュリティ制限をオーバーライドできます。

Replicator 552

レプリケーターは、ドメインでのファイル レプリケーションをサポートします。

次の例は、 WindowsBuiltInRole 列挙体の使用方法を示しています。

public:
   static void DemonstrateWindowsBuiltInRoleEnum()
   {
      AppDomain^ myDomain = Thread::GetDomain();

      myDomain->SetPrincipalPolicy( PrincipalPolicy::WindowsPrincipal );
      WindowsPrincipal^ myPrincipal = dynamic_cast<WindowsPrincipal^>(Thread::CurrentPrincipal);

      Console::WriteLine( "{0} belongs to: ", myPrincipal->Identity->Name );

      Array^ wbirFields = Enum::GetValues( WindowsBuiltInRole::typeid );

      for each ( Object^ roleName in wbirFields )
      {
         try
         {
            Console::WriteLine( "{0}? {1}.", roleName,
               myPrincipal->IsInRole(  *dynamic_cast<WindowsBuiltInRole^>(roleName) ) );
         }
         catch ( Exception^ ) 
         {
            Console::WriteLine( "{0}: Could not obtain role for this RID.",
               roleName );
         }
      }
   }
using System;
using System.Threading;
using System.Security.Permissions;
using System.Security.Principal;

class SecurityPrincipalDemo
{
    public static void DemonstrateWindowsBuiltInRoleEnum()
    {
        AppDomain myDomain = Thread.GetDomain();

        myDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
        WindowsPrincipal myPrincipal = (WindowsPrincipal)Thread.CurrentPrincipal;
        Console.WriteLine("{0} belongs to: ", myPrincipal.Identity.Name.ToString());
        Array wbirFields = Enum.GetValues(typeof(WindowsBuiltInRole));
        foreach (object roleName in wbirFields)
        {
            try
            {
                // Cast the role name to a RID represented by the WindowsBuildInRole value.
                Console.WriteLine("{0}? {1}.", roleName,
                    myPrincipal.IsInRole((WindowsBuiltInRole)roleName));
                Console.WriteLine("The RID for this role is: " + ((int)roleName).ToString());
            }
            catch (Exception)
            {
                Console.WriteLine("{0}: Could not obtain role for this RID.",
                    roleName);
            }
        }
        // Get the role using the string value of the role.
        Console.WriteLine("{0}? {1}.", "Administrators",
            myPrincipal.IsInRole("BUILTIN\\" + "Administrators"));
        Console.WriteLine("{0}? {1}.", "Users",
            myPrincipal.IsInRole("BUILTIN\\" + "Users"));
        // Get the role using the WindowsBuiltInRole enumeration value.
        Console.WriteLine("{0}? {1}.", WindowsBuiltInRole.Administrator,
           myPrincipal.IsInRole(WindowsBuiltInRole.Administrator));
        // Get the role using the WellKnownSidType.
        SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null);
        Console.WriteLine("WellKnownSidType BuiltinAdministratorsSid  {0}? {1}.", sid.Value, myPrincipal.IsInRole(sid));
    }

    public static void Main()
    {
        DemonstrateWindowsBuiltInRoleEnum();
    }
}
Imports System.Threading
Imports System.Security.Permissions
Imports System.Security.Principal

Class SecurityPrincipalDemo

    Public Shared Sub DemonstrateWindowsBuiltInRoleEnum()
        Dim myDomain As AppDomain = Thread.GetDomain()

        myDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)
        Dim myPrincipal As WindowsPrincipal = CType(Thread.CurrentPrincipal, WindowsPrincipal)
        Console.WriteLine("{0} belongs to: ", myPrincipal.Identity.Name.ToString())
        Dim wbirFields As Array = [Enum].GetValues(GetType(WindowsBuiltInRole))
        Dim roleName As Object
        For Each roleName In wbirFields
            Try
                ' Cast the role name to a RID represented by the WindowsBuildInRole value.
                Console.WriteLine("{0}? {1}.", roleName, myPrincipal.IsInRole(CType(roleName, WindowsBuiltInRole)))
                Console.WriteLine("The RID for this role is: " + Fix(roleName).ToString())

            Catch
                Console.WriteLine("{0}: Could not obtain role for this RID.", roleName)
            End Try
        Next roleName
        ' Get the role using the string value of the role.
        Console.WriteLine("{0}? {1}.", "Administrators", myPrincipal.IsInRole("BUILTIN\" + "Administrators"))
        Console.WriteLine("{0}? {1}.", "Users", myPrincipal.IsInRole("BUILTIN\" + "Users"))
        ' Get the role using the WindowsBuiltInRole enumeration value.
        Console.WriteLine("{0}? {1}.", WindowsBuiltInRole.Administrator, myPrincipal.IsInRole(WindowsBuiltInRole.Administrator))
        ' Get the role using the WellKnownSidType.
        Dim sid As New SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, Nothing)
        Console.WriteLine("WellKnownSidType BuiltinAdministratorsSid  {0}? {1}.", sid.Value, myPrincipal.IsInRole(sid))

    End Sub

    Public Shared Sub Main()
        DemonstrateWindowsBuiltInRoleEnum()

    End Sub
End Class

注釈

これらの役割は、Windows NT、Windows 2000、Windows XPのほとんどのインストールに共通するローカル Windows グループを表します。

Note

Windows Vista では、ユーザー アカウント制御 (UAC) によってユーザーの権限が決定されます。 組み込みの Administrators グループのメンバーである場合は、標準ユーザー アクセス トークンと管理者アクセス トークンという 2 つのランタイム アクセス トークンが割り当てられます。 既定では、標準のユーザー ロールになります。 管理特権を必要とするタスクを実行しようとすると、[同意] ダイアログ ボックスを使用してロールを動的に昇格できます。 IsInRole メソッドを実行するコードでは、[同意] ダイアログ ボックスは表示されません。 組み込みの Administrators グループに含まれている場合でも、標準のユーザー ロールを使用している場合、このコードは false を返します。 アプリケーション アイコンを右クリックし、管理者として実行することを示すことで、コードを実行する前に特権を昇格できます。

適用対象