ldap list all OU's for a given DC
- From: "Tom Cat" <stry_cat@xxxxxxxxx>
- Date: 28 Jun 2005 11:24:30 -0700
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>";
}
}
}
}
}
.
- Prev by Date: locales in PHP(5)
- Previous by thread: locales in PHP(5)
- Index(es):
Relevant Pages
|