- All Known Implementing Classes:
ACE
To fully understand the information exposed by this class a description of the access check algorithm used by Windows is required. The following is a basic description of the algorithm. For a more complete description we recommend reading the section on Access Control in Keith Brown's "The .NET Developer's Guide to Windows Security" (which is also available online).
Direct ACEs are evaluated first in order. The SID of the user performing the operation and the desired access bits are compared to the SID and access mask of each ACE. If the SID matches, the allow/deny flags and access mask are considered. If the ACE is a "deny" ACE and any of the desired access bits match bits in the access mask of the ACE, the whole access check fails. If the ACE is an "allow" ACE and all of the bits in the desired access bits match bits in the access mask of the ACE, the access check is successful. Otherwise, more ACEs are evaluated until all desired access bits (combined) are "allowed". If all of the desired access bits are not "allowed" the then same process is repeated for inherited ACEs.
For example, if user WNET\alice tries to open a file
with desired access bits 0x00000003 (FILE_READ_DATA |
FILE_WRITE_DATA) and the target file has the following security
descriptor ACEs:
Allow WNET\alice 0x001200A9 Direct Allow Administrators 0x001F01FF Inherited Allow SYSTEM 0x001F01FF Inheritedthe access check would fail because the direct ACE has an access mask of
0x001200A9 which doesn't have the
FILE_WRITE_DATA bit on (bit 0x00000002). Actually, this isn't quite correct. If
WNET\alice is in the local Administrators group the access check
will succeed because the inherited ACE allows local Administrators
both FILE_READ_DATA and FILE_WRITE_DATA access.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intStandard delete permissionstatic final intPermission to append data to a file or add subdirectoriesstatic final intPermission to delete a file or directorystatic final intPermission to execute a file or traverse a directorystatic final intPermission to read file attributesstatic final intPermission to read data from a file or list directory contentsstatic final intPermission to read extended attributesstatic final intPermission to write file attributesstatic final intPermission to write data to a file or add files to a directorystatic final intPermission to write extended attributesstatic final intInheritance flag: child containers inherit this ACEstatic final intInheritance flag: ACE applies only to children, not to the object itselfstatic final intInheritance flag: ACE was inherited from parentstatic final intInheritance flag: inheritance stops after one levelstatic final intInheritance flag: child objects inherit this ACEstatic final intGeneric all permissionsstatic final intGeneric execute permissionstatic final intGeneric read permissionstatic final intGeneric write permissionstatic final intPermission to read the security descriptorstatic final intPermission to synchronize with the filestatic final intPermission to write the discretionary access control liststatic final intPermission to change the owner in the security descriptor -
Method Summary
Modifier and TypeMethodDescriptionintReturns the access mask associated with this ACE.Returns the 'Apply To' text for inheritance of ACEs on directories such as 'This folder, subfolder and files'.intgetFlags()Returns the flags for this ACE.getSID()Return the SID associated with this ACE.booleanisAllow()Returns true if this ACE is an allow ACE and false if it is a deny ACE.booleanReturns true if this ACE is an inherited ACE and false if it is a direct ACE.
-
Field Details
-
FILE_READ_DATA
static final int FILE_READ_DATAPermission to read data from a file or list directory contents- See Also:
-
FILE_WRITE_DATA
static final int FILE_WRITE_DATAPermission to write data to a file or add files to a directory- See Also:
-
FILE_APPEND_DATA
static final int FILE_APPEND_DATAPermission to append data to a file or add subdirectories- See Also:
-
FILE_READ_EA
static final int FILE_READ_EAPermission to read extended attributes- See Also:
-
FILE_WRITE_EA
static final int FILE_WRITE_EAPermission to write extended attributes- See Also:
-
FILE_EXECUTE
static final int FILE_EXECUTEPermission to execute a file or traverse a directory- See Also:
-
FILE_DELETE
static final int FILE_DELETEPermission to delete a file or directory- See Also:
-
FILE_READ_ATTRIBUTES
static final int FILE_READ_ATTRIBUTESPermission to read file attributes- See Also:
-
FILE_WRITE_ATTRIBUTES
static final int FILE_WRITE_ATTRIBUTESPermission to write file attributes- See Also:
-
DELETE
static final int DELETEStandard delete permission- See Also:
-
READ_CONTROL
static final int READ_CONTROLPermission to read the security descriptor- See Also:
-
WRITE_DAC
static final int WRITE_DACPermission to write the discretionary access control list- See Also:
-
WRITE_OWNER
static final int WRITE_OWNERPermission to change the owner in the security descriptor- See Also:
-
SYNCHRONIZE
static final int SYNCHRONIZEPermission to synchronize with the file- See Also:
-
GENERIC_ALL
static final int GENERIC_ALLGeneric all permissions- See Also:
-
GENERIC_EXECUTE
static final int GENERIC_EXECUTEGeneric execute permission- See Also:
-
GENERIC_WRITE
static final int GENERIC_WRITEGeneric write permission- See Also:
-
GENERIC_READ
static final int GENERIC_READGeneric read permission- See Also:
-
FLAGS_OBJECT_INHERIT
static final int FLAGS_OBJECT_INHERITInheritance flag: child objects inherit this ACE- See Also:
-
FLAGS_CONTAINER_INHERIT
static final int FLAGS_CONTAINER_INHERITInheritance flag: child containers inherit this ACE- See Also:
-
FLAGS_NO_PROPAGATE
static final int FLAGS_NO_PROPAGATEInheritance flag: inheritance stops after one level- See Also:
-
FLAGS_INHERIT_ONLY
static final int FLAGS_INHERIT_ONLYInheritance flag: ACE applies only to children, not to the object itself- See Also:
-
FLAGS_INHERITED
static final int FLAGS_INHERITEDInheritance flag: ACE was inherited from parent- See Also:
-
-
Method Details
-
getSID
SID getSID()Return the SID associated with this ACE.- Returns:
- ACE target SID
-
getAccessMask
int getAccessMask()Returns the access mask associated with this ACE. Use the constants forFILE_READ_DATA,FILE_WRITE_DATA,READ_CONTROL,GENERIC_ALL, etc with bitwise operators to determine which bits of the mask are on or off.- Returns:
- the access mask
-
getApplyToText
String getApplyToText()Returns the 'Apply To' text for inheritance of ACEs on directories such as 'This folder, subfolder and files'. For files the text is always 'This object only'.- Returns:
- descriptive text for the ACE scope
-
getFlags
int getFlags()Returns the flags for this ACE. TheisInherited()method checks theFLAGS_INHERITEDbit in these flags.- Returns:
- the ACE flags
-
isInherited
boolean isInherited()Returns true if this ACE is an inherited ACE and false if it is a direct ACE.Note: For reasons not fully understood,
FLAGS_INHERITEDmay not be set within all security descriptors even though the ACE was in face inherited. If an inherited ACE is added to a parent the Windows ACL editor will rebuild all children ACEs and set this flag accordingly.- Returns:
- whether this is an inherited ACE
-
isAllow
boolean isAllow()Returns true if this ACE is an allow ACE and false if it is a deny ACE.- Returns:
- whether this in an allow ACE
-