Reputation: 43
Given a specific file system path (folder or file, doesn't matter), I need to generate a string that reflects each principal's access to that path.
The result I'm after would be very similar to what you see in the Permissions tab of the Advanced Security Settings dialog in Windows:
which I will ultimately display in a User1: [access], User2: [access], etc.
format.
What is the straight-forward method of achieving this result? Specifically, which Windows security API functions must be executed, and in what order?
Upvotes: 1
Views: 371
Reputation: 104589
Open the file via CreateFile with FILE_FLAG_BACKUP_SEMANTICS and FILE_GENERIC_READ attributes (or'd together).
Then with the obtained file handle, call GetKernelObjectSecurity. Then parse out the SECURITY_DESCRIPTOR that is returned by this call.
You'll likely need to learn about ACLs and DACLs.
Upvotes: 2