In the code below, pGPOList (the GPO list) is always NULL even when the GetAppliedGPOList returns success. I have tried multiple group policy extension GUIDs, but no luck. What am I doing wrong? This also happens when I try GetAppliedGPOList with user policies, although the code is slightly different.
static DWORD DisplayAppliedMachinePolicies()
{
PGROUP_POLICY_OBJECT pGPOList = NULL;
LPGROUPPOLICYOBJECT pGPO = NULL;
UUID guid;
DWORD dwError = 0;
//{17D89FEC-5C44-4972-B12D-241CAEF74509}
//{3A0DBA37-F8B2-4356-83DE-3E90BD5C261F}
//{E47248BA-94CC-49c4-BBB5-9EB7F05183D0}
if (string_to_guid(L"E47248BA-94CC-49c4-BBB5-9EB7F05183D0", &guid) != 0)
{
return ERROR_BAD_FORMAT;
}
dwError = GetAppliedGPOList(GPO_LIST_FLAG_MACHINE, NULL, NULL, &guid, &pGPOList);
if (dwError == ERROR_SUCCESS)
{
PGROUP_POLICY_OBJECT pGPO = (PGROUP_POLICY_OBJECT)pGPOList;
while (pGPO != NULL)
{
//Display properties of each GPO
DisplayPolicyInfo((PGROUP_POLICY_OBJECT)&pGPOList);
pGPO = pGPO->pNext;
}
FreeGPOList((PGROUP_POLICY_OBJECT)pGPOList);
}
return dwError;
}