I have a PHP array which gives this result:
Array
(
[count] => 1
[0] => Array
(
[sn] => Array
(
[count] => 1
[0] => Smith
)
[0] => sn
[givenname] => Array
(
[count] => 1
[0] => John
)
[1] => givenname
[mail] => Array
(
[count] => 1
[0] => john.smith@mydomain.com
)
[2] => mail
[count] => 3
[dn] => CN=John Smith,OU=IT Admin,DC=mylocaldomain,DC=local
)
)
How do I go about extracting the Email address from this array result into a single string? I need to able to reference the Email address, but can't find a way to pull that information out.
The meat of the LDAP code is along the lines of:
$dn = “OU=IT Admin,DC=mylocaldomain,DC=local”;
$ds = $ldapconnectionstring;
$person = “johnsmith”;
$filter="(|(sn=$person*)(samaccountname=$person*))";
$justthese = array("ou", "sn", "givenname", "mail");
$sr=ldap_search($ds, $dn, $filter, $justthese);
$info = ldap_get_entries($ds, $sr);
echo '<pre>'; print_r($info); echo '<pre/>';
I've googled this to death, read the PHP documentation about arrays, and read various similar posts here, but nothing seems to work for me.
I need to end up with:
echo $email;
and get back:
john.smith@mydomain.com