I'm using CreateFile to get a handle to a file to add ACE to its DACL. The problem is, when the file has no permissions, I get access denied error when I call the function CreateFile, I'm the OWNER of the file and Admin. If I using explorer I can add permissions.
I'm not interested in other functions such as OpenFile or Set security descriptor directly, I'm interested in the right combination to open such files.
I've read in MSDN that I have to use specific access right, I've tried:
CreateFile(lpFileName, READ_CONTROL | WRITE_DAC, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS);
CreateFile(lpFileName, READ_CONTROL | WRITE_DAC, 0, NULL, OPEN_EXISTING, ACCESS_SYSTEM_SEURITY);
Both I get the access denied. Any ideas?
Thanks, Gabi