<?php
$ldapurl = 'ldaps://ldap.example.com/';
$ldapproxydn = '<proxy-dn>';
$ldapproxypassword = '<proxy-password>';
$connection = ldap_connect($ldapurl);
if (!$connection) {
echo 'Unable to connect to an LDAP server. (Debug 1)';
return 0;
}
@ldap_set_option($connection, LDAP_OPT_PROTOCOL_VERSION, 3);
@ldap_set_option($connection, LDAP_OPT_REFERRALS, 0);
// Connection made -- bind
$bind = @ldap_bind($connection, $ldapproxydn, $ldapproxypassword);
if (!$bind) {
echo 'Bind to LDAP failed:', ldap_error($connection), ' (Debug 3)';
return 0;
} else {
echo 'Success!';
}
ldap_close($connection);
?>
ini_set('display_errors', 1); error_reporting(E_ALL);