I am accessing the DACL for a user, with a given file.
I am able to grant and deny any given permission, but
when I grant certain permissions, I see that several
others are granted along with it.
For example, I can get an "IdentityReference" for a given user,
purge the access rules, then grant read access:
==============================================================
Read access gets set, but so does a lot of other things:
----------------------------------------
<grant>
<FullControl/>
<ListDirectory/>
<Modify/>
<Read/>
<ReadAndExecute/>
<ReadAttributes/>
<ReadData/>
<ReadExtendedAttributes/>
<ReadPermissions/>
<Synchronize/>
</grant>
----------------------------------------
On testing the enumeration, I simply perform
a bit-wise and ("&") for each of the values
within the enumerated list "FileSystemRights".
Examining the security settings with Windows Explorer
shows that only read access has been granted for the
given file (as was intended). There is something that
I am missing.
When you test an attribute, you do not perform a bit-wise and comparison
- or, I should type, you don't stop with that.
After the bit-wise and comparison, you then compare the result back to the
attribute for the file being evaluated ("==") to determine if all of the bits are set.
I KNEW I was missing something, and I finally figured it out.