Like "65536" represent "Delete" in FileSystemRights. Then what does "269681087" represent in FileSystemRights?
Thank you!
Aleady read: https://learn.microsoft.com/zh-tw/dotnet/api/system.security.accesscontrol.filesystemrights?view=net-6.0
CodePudding user response:
The value should be a combination of flags from that FileSystemRights enum.
For instance FileSystemRights.ReadData | FileSystemRights.WriteData
allows both reading and writing of data. That |
is the bitwise OR operator.
Code to test for specific values:
var val = (System.Security.AccessControl.FileSystemRights)269681087;
foreach(FileSystemRights fsr in Enum.GetValues(typeof(FileSystemRights)))
{
if ((val & fsr) == fsr)
{
Console.WriteLine($"{fsr} (0x{(int)fsr:X} = {(int)fsr})");
}
}
This gives a list of values, with some apparent duplicates. The reason is that for instance AppendData and CreateDirectories share the same underlying value (4) so the ToString (implicit in that {fsr}
) cannot distinguish between them and chooses the first matching text value.
ReadData (0x1 = 1)
ReadData (0x1 = 1) = ListDirectory
CreateFiles (0x2 = 2)
CreateFiles (0x2 = 2) = WriteData
AppendData (0x4 = 4)
AppendData (0x4 = 4) = CreateDirectories
ReadExtendedAttributes (0x8 = 8)
WriteExtendedAttributes (0x10 = 16)
ExecuteFile (0x20 = 32)
ExecuteFile (0x20 = 32) = Traverse
ReadAttributes (0x80 = 128)
WriteAttributes (0x100 = 256)
Write (0x116 = 278)
Delete (0x10000 = 65536)
ReadPermissions (0x20000 = 131072)
Read (0x20089 = 131209)
ReadAndExecute (0x200A9 = 131241)
Modify (0x301BF = 197055)
Synchronize (0x100000 = 1048576)
But even then, when I combine all matching values I don't get your original value back: a value 0x1000_0000 is unaccounted for.