Dear Friends,
Application demanding Admin rights, when I install application in client PC. All supporting files pasted under "C:" driver. Due to insufficient privilege (read and Write) the application couldnt to create file or read a file from "C:"
driver (supporting file in "C:\"). I have tired out some of the program to grant privilege. But no use in it.
void AllowEveryone()
{
PACL pDacl,pNewDACL;
EXPLICIT_ACCESS ExplicitAccess;
PSECURITY_DESCRIPTOR ppSecurityDescriptor;
PSID psid;
LPTSTR lpStr;
// char str[5] = path;
//lpStr = str.GetBuffer();
lpStr = _T("C:");
GetNamedSecurityInfo(lpStr, SE_FILE_OBJECT,DACL_SECURITY_INFORMATION, NULL, NULL, &pDacl, NULL, &ppSecurityDescriptor);
ConvertStringSidToSid(_T("S-1-1-0"), &psid);
ExplicitAccess.grfAccessMode = SET_ACCESS;
ExplicitAccess.grfAccessPermissions = GENERIC_ALL;
ExplicitAccess.grfInheritance = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE;
ExplicitAccess.Trustee.MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
ExplicitAccess.Trustee.pMultipleTrustee = NULL;
ExplicitAccess.Trustee.ptstrName = (LPTSTR) psid;
ExplicitAccess.Trustee.TrusteeForm = TRUSTEE_IS_SID;
ExplicitAccess.Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN;
SetEntriesInAcl(1, &ExplicitAccess, pDacl, &pNewDACL);
SetNamedSecurityInfo(lpStr,SE_FILE_OBJECT,DACL_SECURITY_INFORMATION,NULL,NULL,pNewDACL,NULL);
LocalFree(pNewDACL);
LocalFree(psid);
}
int _tmain(int argc, _TCHAR* argv[])
{
AllowEveryone();
return 0;
}
Folks, your suggestion higly appreciated and it means a lot to me.
Thanks and Regards,
S Shanmuga Raja