Jump to content

[C++] SetSecurityInfo


Recommended Posts

Hello all,

I am trying to change the security permissions for a file/folder to allow or deny full control to a specific user. However I get an access denied in setting the security info for the following code:

hFile = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL);

rc = GetSecurityInfo(hFile, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, &pDACL, NULL, &pSD);

rc = SetEntriesInAcl(1, &eb, pDACL, &pNewDACL);

rc = SetSecurityInfo(hFile, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, NULL, NULL, pNewDACL, NULL);

I don't get any errors until the SetSecurityInfo call and it returns 'Access is denied'.

Any ideas on what I am doing wrong?

Thanks.

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...