openldap.org/). For Windows,
numerous free and commercial solutions are available, although Lucas Bergman??™s OpenLDAP binaries for
Windows seem to be particularly popular. See http://www.bergmans.us/ for more information.
Connecting to an LDAP Server
The ldap_connect() function establishes a connection to an LDAP server identified
by a specific host name and optionally a port number. Its prototype follows:
resource ldap_connect([string hostname [, int port]])
If the optional port parameter is not specified, and the ldap:// URL scheme prefaces
the server or the URL scheme is omitted entirely, LDAP??™s standard port 389 is
assumed. If the ldaps:// scheme is used, port 636 is assumed. If the connection is
successful, a link identifier is returned; on error, FALSE is returned. A simple usage
example follows:
$host = "ldap.openldap.org";
$port = "389";
$connection = ldap_connect($host, $port)
or die("Can't establish LDAP connection");
?>
428 CHAPTER 17 ?– PHP AND LDAP
Although Secure LDAP (LDAPS) is widely deployed, it is not an official specification.
OpenLDAP 2.0 does support LDAPS, but it??™s actually been deprecated in favor of
another mechanism for ensuring secure LDAP communication known as Start TLS.
Securely Connecting Using the Transport Layer Security Protocol
Although not a connection-specific function per se, ldap_start_tls() is introduced
in this section nonetheless because it is typically executed immediately after a call to
ldap_connect() if the developer wants to connect to an LDAP server securely using the
Transport Layer Security (TLS) protocol.
Pages:
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507