Reputation: 1779
I have a php application which is querying an LDAP server. Using the LDAP Browser desktop application I can see users listed as: cn=joebloe,ou=users,ou=people,o=cuid
with attributes like: 'departmentNumber', 'loginDisabled' etc.
Inside my php application, I have this code:
$sr = ldap_search($ds, "o=$o", "cn=joebloe,ou=users,ou=people,o=cuid");
but that code me wrong and just returns a resource link; it would be nice if I can get the value of the attribute of 'loginDisabled'.
How can I do that? Thanks!
Upvotes: 1
Views: 12978
Reputation: 22947
If you are wanting to get the information on joebloe
, then you should be searching for him. I think your base DN string is a little too specific.
Try this out:
$search = ldap_search($ds, "ou=users,ou=people,o=cuid", "cn=joeblow");
$results = ldap_get_entries($ds, $search);
var_dump($results);
// Print Department Number
echo "Department Number = ".$results[0]['departmentNumber'][0];
Upvotes: 2
Reputation: 6429
Take a look to http://es2.php.net/manual/en/function.ldap-search.php and http://es2.php.net/manual/es/function.ldap-get-entries.php
<?php
// $ds is a valid link identifier for a directory server
// $person is all or part of a person's name, eg "Jo"
$dn = "o=My Company, c=US";
$filter="(|(sn=$person*)(givenname=$person*))";
$justthese = array("ou", "sn", "givenname", "mail");
$sr=ldap_search($ds, $dn, $filter, $justthese);
$info = ldap_get_entries($ds, $sr);
echo $info["count"]." entries returned\n";
?>
Snippet copied from PHP Manual
Upvotes: 3