Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using CreateFile Win32 API 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'm using windows 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 of permissions and flags to open such files with the CreateFile function.

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);


With these combinations I get the access denied. Any ideas?

Thanks, Gabi
Posted
Updated 9-Aug-11 9:38am
v3
Comments
KarstenK 10-Aug-11 5:06am    
READ_CONTROL <==> WRITE_DAC ??? only an idea
wILDFriCK 12-Aug-11 18:35pm    
what do you mean? replace them?
KarstenK 19-Aug-11 3:45am    
You want "read" control and than "write". This doenst match.

please think more....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900