Is there a way to read windows firewall policies from GPO using win32 API's?
I was trying to use GetGPOList() api but it fails with error 2148074274 . Which is an Active Directory replication error (REF https://learn.microsoft.com/en-us/troubleshoot/windows-server/identity/replication-error-2146893022) . I don't know what is causing this error .
But even if that api succeeds , I am not sure it will give access to firewall policy.
Here is my code for ref:
bool success = OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &hToken);
if (!success)
{
printf("OpenProcessToken failed Error(%d)\n", GetLastError());
return;
}
else
{
printf("OpenProcessToken success \n");
}
success = GetGPOList(hToken, NULL, NULL, NULL, GPO_LIST_FLAG_MACHINE, &pGPOList);
if (success)
{
// Perform processing here.
while (pGPOList)
{
printf("%ls \n", pGPOList->lpDisplayName);
}
// Free the GPO list when you finish processing.
FreeGPOList(pGPOList);
}
else
{
printf("GetGPOList failed %lu\n", GetLastError());
}