delphiwinapiicaclsdacl

Looking for a way to get file/folder permissions equivalent to ICACLS.EXE


I'm using Delphi 11.3 Alexandria. How do I get file/folder permissions on Windows?

On a command line, I can use icacls /save, but would prefer a direct call. I get the below result, which I can use with /Restore and apply again:

Abc
D:(A;ID;0x1301bf;;;AU)(A;OICIIOID;SDGXGWGR;;;AU)(A;OICIID;FA;;;SY)(A;OICIID;FA;;;BA)(A;OICIID;0x1200a9;;;BU)

Solution

  • You can retrieve DACLs with GetNamedSecurityInfo() or Low-level Security Descriptor Functions and Low-level ACL and ACE Functions.

    Then you can list ACEs for example dcomperm.

    And according to Security Descriptor String Format,

    The ConvertSecurityDescriptorToStringSecurityDescriptor function converts a security descriptor to a string format. You can use the string format to store or transmit the security descriptor.