Php Programming Code Examples
Php > LDAP Code Examples
Connect to an LDAP server
Connect to an LDAP server
// Example of connecting to LDAP server.
<?php
// LDAP variables
$ldaphost = "ldap.example.com"; // your ldap servers
$ldapport = 389; // your ldap server's port number
// Connecting to LDAP
$ldapconn = ldap_connect( $ldaphost, $ldapport )
or die( "Could not connect to {$ldaphost}" );
?>
// Example of connecting securely to LDAP server.
<?php
// make sure your host is the correct one
// that you issued your secure certificate to
$ldaphost = "ldaps://ldap.example.com/";
// Connecting to LDAP
$ldapconn = ldap_connect( $ldaphost )
or die( "Could not connect to {$ldaphost}" );
?>