C# Класс SharpCifs.Smb.Ace

An Access Control Entry (ACE) is an element in a security descriptor such as those associated with files and directories.
An Access Control Entry (ACE) is an element in a security descriptor such as those associated with files and directories. The Windows OS determines which users have the necessary permissions to access objects based on these entries.

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  Inherited 
the 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.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
GetAccessMask ( ) : int

Returns the access mask accociated with this ACE.

Returns the access mask accociated with this ACE. Use the constants for FILE_READ_DATA, FILE_WRITE_DATA, READ_CONTROL, GENERIC_ALL, etc with bitwise operators to determine which bits of the mask are on or off.

GetApplyToText ( ) : string

Returns the 'Apply To' text for inheritance of ACEs on directories such as 'This folder, subfolder and files'.

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'.

GetFlags ( ) : int

Returns the flags for this ACE.

Returns the flags for this ACE. The isInherited() method checks the FLAGS_INHERITED bit in these flags.

GetSid ( ) : Sid

Return the SID associated with this ACE.

Return the SID associated with this ACE.

IsAllow ( ) : bool

Returns true if this ACE is an allow ACE and false if it is a deny ACE.

Returns true if this ACE is an allow ACE and false if it is a deny ACE.

IsInherited ( ) : bool

Returns true if this ACE is an inherited ACE and false if it is a direct ACE.

Returns true if this ACE is an inherited ACE and false if it is a direct ACE.

Note: For reasons not fully understood, FLAGS_INHERITED may 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.

ToString ( ) : string

Return a string represeting this ACE.

Return a string represeting this ACE.

Note: This function should probably be changed to return SDDL fragments but currently it does not.

Приватные методы

Метод Описание
AppendCol ( StringBuilder sb, string str, int width ) : void
Decode ( byte buf, int bi ) : int

Описание методов

GetAccessMask() публичный Метод

Returns the access mask accociated with this ACE.
Returns the access mask accociated with this ACE. Use the constants for FILE_READ_DATA, FILE_WRITE_DATA, READ_CONTROL, GENERIC_ALL, etc with bitwise operators to determine which bits of the mask are on or off.
public GetAccessMask ( ) : int
Результат int

GetApplyToText() публичный Метод

Returns the 'Apply To' text for inheritance of ACEs on directories such as 'This folder, subfolder and files'.
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'.
public GetApplyToText ( ) : string
Результат string

GetFlags() публичный Метод

Returns the flags for this ACE.
Returns the flags for this ACE. The isInherited() method checks the FLAGS_INHERITED bit in these flags.
public GetFlags ( ) : int
Результат int

GetSid() публичный Метод

Return the SID associated with this ACE.
Return the SID associated with this ACE.
public GetSid ( ) : Sid
Результат Sid

IsAllow() публичный Метод

Returns true if this ACE is an allow ACE and false if it is a deny ACE.
Returns true if this ACE is an allow ACE and false if it is a deny ACE.
public IsAllow ( ) : bool
Результат bool

IsInherited() публичный Метод

Returns true if this ACE is an inherited ACE and false if it is a direct ACE.
Returns true if this ACE is an inherited ACE and false if it is a direct ACE.

Note: For reasons not fully understood, FLAGS_INHERITED may 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.

public IsInherited ( ) : bool
Результат bool

ToString() публичный Метод

Return a string represeting this ACE.
Return a string represeting this ACE.

Note: This function should probably be changed to return SDDL fragments but currently it does not.

public ToString ( ) : string
Результат string