need to display info for user within active-directory
Posted
by Brad
on Stack Overflow
See other posts from Stack Overflow
or by Brad
Published on 2010-03-17T16:15:49Z
Indexed on
2010/03/17
17:01 UTC
Read the original article
Hit count: 273
The following code will search for the user within the domain controller, but I want to display the info of each thing noted within the justthese variable: "displayname","mail","samaccountname","sn","givenname","department","telephonenumber"
$dn = "dc=xxx,dc=xxx";
$justthese = array("displayname","mail","samaccountname","sn","givenname","department","telephonenumber");
$sr=ldap_search($ldapconn, $dn,'SAMAccountName=username', $justthese);
$info = ldap_get_entries($ldapconn, $sr);
echo "<h3>".$info["count"]." entries returned</h3>";
foreach($justthese as $key=>$value){
print '<p><strong>'.$value.'</strong></p>';
}
It displays each item within the $justthese array, I want to display the info for that user for each thing noted in $justthese array.
Right now it outputs it like this:
displayname
samaccountname
sn
givenname
department
telephonenumber
I want it to have the actual data to the right of it, which I know I am doing something wrong with the foreach loop, any help is appreciated.
So it'd look like this
displayname Chuck
mail [email protected]
samaccountname chucknorris
sn chuckisthebest
givenname Chuck Norris
department Security
telephonenumber 555-555-5555
© Stack Overflow or respective owner