Query GPOs by Group

This tool is intended to help determine what OU to use for a specific group.
Users often request systems with a certain security group assigned.
Since AD has no way to look this up, this makes it challenging to match groups to OUs.

This site has all restricted groups indexed by GPO and OU.
Search is case insensitive and supports partial match.
The OUs liked to the GPOs will show up as a hover tooltip on the GPO name.
Clicking on the GPO name will list all linked OUs.


Return Home
'; $group = urlencode($_GET['group']); $url = "http://172.17.0.1:5000/gpo?group=$group"; // query API $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_URL, $url); $response = curl_exec($ch); if ($e = curl_error($ch)) { die("Curl error: $e"); } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($httpCode != 200) { die("Error: Received HTTP code $httpCode"); } curl_close($ch); $data = json_decode($response, true); $numResults = count($data); // build the group array $gpoMap = []; // will look like: [ 'GPO‑Name' => ['Administrator' => [...], 'vnc_admin' => [...]] ] if (isset($data['error'])) { echo "

Error: {$data['error']}

"; } else { foreach ($data as $row) { // safety: skip rows that do not contain the expected keys if (!isset($row['gpo'], $row['ad_group'], $row['local_group'])) { continue; } $gpoName = $row['gpo']; $adGroup = $row['ad_group']; $localGroup = strtolower($row['local_group']); // initialise if not already done if (!isset($gpoMap[$gpoName])) { $gpoMap[$gpoName] = [ 'administrators' => [], 'vnc_admin' => [] ]; } // put the ad_group into the right bucket if ($localGroup === 'administrators') { $gpoMap[$gpoName]['administrators'][] = $adGroup; } elseif ($localGroup === 'vnc_admin') { $gpoMap[$gpoName]['vnc_admin'][] = $adGroup; } } ksort($gpoMap, SORT_STRING | SORT_FLAG_CASE); if($numResults > 0){ echo ' Total results: '.$numResults.'
Data indexed at '.$yaml_timestamp['timestamp'].' after '.$index_duration['duration'].' minutes
Total Linked GPOs: '.$gpo_links['gpo_links'].'

'; foreach ($gpoMap as $gpoName => $cols) { // Remove duplicates and build comma‑separated lists $adminGroups = implode('
', array_unique($cols['administrators'])); $vncGroups = implode('
', array_unique($cols['vnc_admin'])); $linkedOUs = implode("\n", getLinkedOUs($gpoName)); echo " "; } echo '
GPO Administrators vnc_admin
{$adminGroups} {$vncGroups}
'; } else{ echo 'No results found for query '.$_GET['group'].'.

'; } } } // if you click on a GPO name, print all OUs else if (isset($_GET['gpo'])) { echo 'OUs linked to GPO '.$_GET['gpo'].':

Return Home'; } else { echo '

Data indexed at '.$yaml_timestamp['timestamp'].' after '.$index_duration['duration'].' minutes
Total Linked GPOs: '.$gpo_links['gpo_links'].'

No group specified.

'; } echo "
"; //echo "

Source code can be found here.

"; ?>