I'm trying to use GetNamedSecurityInfo() but I keep getting out of scope errors:
main.cpp:25:3: error: 'SDDL_REVISION_1' was not declared in this scope
SDDL_REVISION_1, DACL_SECURITY_INFORMATION, secDescBuffer, buflen);
^
main.cpp:25:68: error: 'ConvertSecurityDescriptorToStringSecurityDescriptor' was not declared in this scope
SDDL_REVISION_1, DACL_SECURITY_INFORMATION, secDescBuffer, buflen);
Here is the code:
#include "windows.h"
#include "sddl.h"
#include "aclapi.h"
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
PACL pACL = NULL;
DWORD dwRes = 0;
PSECURITY_DESCRIPTOR pSecDesc = NULL;
dwRes = GetNamedSecurityInfo(TEXT("C:\\somefile.txt"),
SE_FILE_OBJECT, DACL_SECURITY_INFORMATION,
NULL, NULL, &pACL, NULL, &pSecDesc);
if (ERROR_SUCCESS == dwRes) {
LPTSTR * secDescBuffer = NULL;
PULONG buflen = NULL;
dwRes = ConvertSecurityDescriptorToStringSecurityDescriptor(pSecDesc,
SDDL_REVISION_1, DACL_SECURITY_INFORMATION, secDescBuffer, buflen);
} else {
printf("GetNamedSecurityInfo Error %lu\n", dwRes);
}
...
I know it uses the sddl.h header, and it definitely exists with no compile errors referring directly to it. What am I missing here?
edit: I am using netbeans and minGW toolchain. I have the Windows SDK, and have been using other parts just fine (like GetNamedSecurityInfo as shown in the example).