Export (0) Print
Expand All

WindowsBuiltInRole Enumeration

Specifies common roles to be used with IsInRole.

Namespace: System.Security.Principal
Assembly: mscorlib (in mscorlib.dll)

[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public enum WindowsBuiltInRole
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public enum WindowsBuiltInRole
SerializableAttribute 
ComVisibleAttribute(true) 
public enum WindowsBuiltInRole

 Member nameDescription
AccountOperatorAccount operators manage the user accounts on a computer or domain. 
AdministratorAdministrators have complete and unrestricted access to the computer or domain. 
BackupOperatorBackup operators can override security restrictions for the sole purpose of backing up or restoring files. 
GuestGuests are more restricted than users. 
PowerUserPower users possess most administrative permissions with some restrictions. Thus, power users can run legacy applications, in addition to certified applications. 
PrintOperatorPrint operators can take control of a printer. 
ReplicatorReplicators support file replication in a domain. 
SystemOperatorSystem operators manage a particular computer. 
UserUsers are prevented from making accidental or intentional system-wide changes. Thus, users can run certified applications, but not most legacy applications. 

These roles represent the local Windows groups common to most installations of Windows NT, Windows 2000 and Windows XP.

The following example shows the use of the WindowsBuiltInRole enumeration.


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
        {
            Console.WriteLine("{0}? {1}.", roleName,
                myPrincipal.IsInRole((WindowsBuiltInRole)roleName));
        } 
        catch (Exception)
        {
            Console.WriteLine("{0}: Could not obtain role for this RID.",
                roleName);
        }
    }        

}


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

    myDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

    WindowsPrincipal myPrincipal = ((WindowsPrincipal)
        (Thread.get_CurrentPrincipal()));

    Console.WriteLine("{0} belongs to: ",
        myPrincipal.get_Identity().get_Name().ToString());

    Array wbirFields = Enum.GetValues(WindowsBuiltInRole.class.ToType());

    for (int iCtr = 0; iCtr < wbirFields.get_Count(); iCtr++) {
        Object roleName = wbirFields.get_Item(iCtr);
        try {
            Console.WriteLine("{0}? {1}.", roleName, 
            System.Convert.ToString(myPrincipal.
            IsInRole(((WindowsBuiltInRole)(roleName)))));
        }
        catch (System.Exception exp) {
            Console.WriteLine(
                "{0}: Could not obtain role for this RID.", roleName);
        }
    }
} //DemonstrateWindowsBuiltInRoleEnum

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft