ldap list all OU's for a given DC



Is there a way I can use PHP to list all of the OU's for a given DC?

I have a script which will search and return results on various CN's,
but when I try ou=* it returns nothing.

The PHP script is being run under Apache2, PHP 4.x. The LPAP server is
an MS Active Directory on Win2k.

Can anyone help?

Here's my script:

$ldap_server = "ldap://ldap.mydomain";;
$auth_user = "strycat@xxxxxxxxxxxxxxx";
$auth_pass = "MyPassword";
$base_dn = "DC=domain1, DC=domain2";

$filter = "(cn=*)"; # WANT TO CHANGE THIS TO LIST THE OU'S

if (!($connect=ldap_connect($ldap_server))) {
die("Could not connect to ldap server");
}

if (!($bind=ldap_bind($connect, $auth_user, $auth_pass))) {
die("Unable to bind to server");
}

if (!($search=ldap_search($connect, $base_dn, $filter))) {
die("Unable to search ldap server");
}
$number_returned = ldap_count_entries($connect,$search);
$info = ldap_get_entries($connect, $search);

// This really should be done with a recrusive extractor function
foreach ($info as $key => $value) {

echo "<hr>$key ==> $value<BR>";

if (is_array($value)) {

foreach ($value as $k1 => $v1) {

echo "---------$k1 ==> $v1<BR>";

if (is_array($v1)) {

foreach ($v1 as $k2=>$v2) {

echo "------------------$k2 ==> $v2<BR>";

}


}


}

}


}

.



Relevant Pages

  • mysqli error?
    ... I'm just setting up my php enviroment and I typed in a simple script ... # configuration directives that give the server its instructions. ...
    (comp.lang.php)
  • Re: How do we get there from here?
    ... >> executing on the server as a pre-processor. ... If there are client side versions of PHP, ... > name implies a static text file, is it different from a PHP script? ...
    (comp.databases.pick)
  • Re: Apache: limiting the execution place
    ... They want it so users can't use FTP, shell, or a CGI or PHP script to view, ... other users via shell, FTP, web server processes (such as PHP or CGI ...
    (Security-Basics)
  • Re: PHP chmod Newbie Question
    ... How does the server keep ... how do I create user groups for chmod to recognize? ... CHMOD is for UNIX based servers, and the PHP chmod() ... edited or removed by the PHP script, and only read by the UNIX ...
    (comp.lang.php)
  • Re: PHP in html
    ... additional calls to the server, ... to invoke a script handler for every single image. ... configuration of the webserver and the PHP interpreter. ... If you think interpreting all pages as PHP ...
    (comp.lang.php)