WindowsBuiltInRole Enumeration
.NET Framework 2.0
Specifies common roles to be used with IsInRole.
Namespace: System.Security.Principal
Assembly: mscorlib (in mscorlib.dll)
Assembly: mscorlib (in mscorlib.dll)
'Declaration <SerializableAttribute> _ <ComVisibleAttribute(True)> _ Public Enumeration WindowsBuiltInRole 'Usage Dim instance As WindowsBuiltInRole
/** @attribute SerializableAttribute() */ /** @attribute ComVisibleAttribute(true) */ public enum WindowsBuiltInRole
SerializableAttribute ComVisibleAttribute(true) public enum WindowsBuiltInRole
| Member name | Description | |
|---|---|---|
| AccountOperator | Account operators manage the user accounts on a computer or domain. | |
| Administrator | Administrators have complete and unrestricted access to the computer or domain. | |
| BackupOperator | Backup operators can override security restrictions for the sole purpose of backing up or restoring files. | |
| Guest | Guests are more restricted than users. | |
| PowerUser | Power users possess most administrative permissions with some restrictions. Thus, power users can run legacy applications, in addition to certified applications. | |
| PrintOperator | Print operators can take control of a printer. | |
| Replicator | Replicators support file replication in a domain. | |
| SystemOperator | System operators manage a particular computer. | |
| User | Users are prevented from making accidental or intentional system-wide changes. Thus, users can run certified applications, but not most legacy applications. |
The following example shows the use of the WindowsBuiltInRole enumeration.
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 Console.WriteLine("{0}? {1}.", roleName, _ myPrincipal.IsInRole(CType(roleName, WindowsBuiltInRole))) Catch Console.WriteLine("{0}: Could not obtain the role for this RID.", roleName) End Try Next roleName End Sub 'DemonstrateWindowsBuiltInRoleEnum
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.
Community Additions
ADD
Show: