Jump to content

PHP LDAP query to list all security groups not returning managedBy


Deborah

Recommended Posts

I am new to PHP and Active Directory.

I am trying to query active directory using PHP.  I have been able to query and get a list of all security groups with the given filters.  I can't however seem to get the managedBy attribute returned.  I would actually like to get the Display Name of the ManagedBY dn.

 

My goal is to have a list of all security groups, grouped by the ManagedBy Person. 

 

Here is the code I'm using.  Any help would be appreciated.

 

<?php

 

// Include code to connect to ldap server

include("ldap_connect.php");

 

// Base dn for search

$base_dn = "dc=oilstates, dc=net";

 

// Filter for search

//$filter = "(|(groupType=-2147483640)(groupType=-2147483646)(groupType=-2147483644))"; //| means or so only one condition must be met

 

// This filter is only for testing purposes The one above is the one that shows all security groups

$filter = "(&(groupType=-2147483646)(name=*IT -*))";

 

// Specify only those parameters we're interested in displaying

$attributes = array("name","description", "managedBy", "info");

 

// $connect comes from ldap_connect.php

$search = ldap_search($connect, $base_dn, $filter, $attributes)

      or exit(">>Unable to search ldap server<<");

 

$info = ldap_get_entries($connect, $search);

 

echo $info["count"]." entries returned<p>";

 

for ($i=0; $i<$info["count"]; $i++)

{

    echo $info[$i]["name"] [0]." (".$info[$i]["description"][0].") ".$info[$i]["info"][0]."<br />";

echo " - ".$info[$i]["managedBy"][0]."<br />";

  }

ldap_unbind($connect);

?>

 

Deborah

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.