Click to See Complete Forum and Search --> : Getting SACL & Privilege Problem


akhin
July 3rd, 2007, 04:43 AM
I cant get SACL structure of a file , however i call a function : Privilege(SE_SECURITY_NAME,TRUE);

How can i get sacl ??

BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
{
HANDLE hToken;
TOKEN_PRIVILEGES tp;

//
// obtain the token, first check the thread and then the process
//
if (!OpenThreadToken(GetCurrentThread(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, TRUE, &hToken)){
if (GetLastError() == ERROR_NO_TOKEN){
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
return FALSE;
}
else
return FALSE;
}

//
// get the luid for the privilege
//
if (!LookupPrivilegeValue(NULL, pszPrivilege, &tp.Privileges[0].Luid))
return FALSE;

tp.PrivilegeCount = 1;

if (bEnable)
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
else
tp.Privileges[0].Attributes = 0;

//
// enable or disable the privilege
//
if (!AdjustTokenPrivileges(hToken, FALSE, &tp, 0, (PTOKEN_PRIVILEGES)NULL, 0))
return FALSE;

if (!CloseHandle(hToken))
return FALSE;

return TRUE;
}

Krishnaa
July 3rd, 2007, 05:14 AM
What do you mean by "I cant get SACL structure of a file"? The sample code you posted here does nothing like that, it only enables the priviledes if the user (under whoz context it is running) have it assigned.