Prev | Current Page 498 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

One function, ldap_unbind(),
is available for doing just this. Its prototype follows:
boolean ldap_unbind(resource link_id)
430 CHAPTER 17 ?–  PHP AND LDAP
The ldap_unbind() function terminates the LDAP server connection associated
with link_id. A usage example follows:
// Connect to the server
$connection = ldap_connect("ldap.openldap.org")
or die("Can't establish LDAP connection");
// Bind to the server
ldap_bind($connection) or die("Can't bind to LDAP.");
// Execute various LDAP-related commands...
// Close the connection
ldap_unbind($connection)
or die("Could not unbind from LDAP server.");
?>
?– Note The PHP function ldap_close() is operationally identical to ldap_unbind(), but because
the LDAP API refers to this function using the latter terminology, it is recommended over the former for
reasons of readability.
Retrieving LDAP Data
Because LDAP is a read-optimized protocol, it makes sense that a bevy of useful data
search and retrieval functions would be offered within any implementation. Indeed,
PHP offers numerous functions for retrieving directory information. Those functions
are examined in this section.
Searching for One or More Records
The ldap_search() function is one you??™ll almost certainly use on a regular basis
when creating LDAP-enabled PHP applications because it is the primary means for
searching a directory based on a specified filter.


Pages:
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510