$user = "XXXXXX";
$password = "XXXXXX";
$ldapuri = "ldaps://ldap.liho.tw";
$basedn = "dc=liho,dc=tw";
$ldaprdn = "uid=".$user.",ou=people,".$basedn;
// Connecting to LDAP
$ldapconn = ldap_connect($ldapuri, 636)
or die("Could not connect to LDAP server.");
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
if ($ldapconn) {
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $password);
// verify binding
if ($ldapbind) {
echo "LDAP bind successful...";
} else {
echo "LDAP bind failed...";
}
}