Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

element. The attributes for the entry may be referenced by name or by number. Each
attribute has its own count element and a numbered set of values.


array ldap_get_values(integer link, integer entry, string
attribute)


The ldap_get_values function returns an array of every value for a given attribute.
The values will be treated as strings. Use ldap_get_values_len if you need to get
binary data.


<?


//connect to LDAP server
if(!($ldap=ldap_connect("ldap.php.net")))
{
die("Could not connect to LDAP server!");
}


//set up search criteria
$dn = "cn=John Smith, dc=php, dc=net";
$filter = "sn=*";
$attributes = array("givenname", "sn", "mail");


//perform search
if(!($result = ldap_read($ldap, $dn, $filter,
$attributes)))
{
die("Nothing Found!");
}


$entry = ldap_first_entry($ldap, $result);
$values = ldap_get_values($ldap, $entry, "mail");


print($values["count"]. " Values:

    \n");


    for($index=0; $index < $values["count"]; $index++)
    {
    print("

  1. $values[$index]\n");
    }


    print("

\n");


ldap_free_result($result);
?>

Free download pdf