I want to point out that the line that reads
"$ldaprdn = 'uname';"
is a bit confusing. You need to ensure that you use the entire rootdn. for instance. your code should look more like this...
<?php
$ldaprdn = 'cn=root,dc=testserver,dc=com'; $ldappass = 'secret'; $ldapconn = ldap_connect("ldap.testserver.com")
or die("Could not connect to LDAP server.");
if (ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) {
echo "Using LDAPv3";
} else {
echo "Failed to set protocol version to 3";
}
if ($ldapconn) {
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
if ($ldapbind) {
echo "LDAP bind successful...";
} else {
echo "LDAP bind failed...";
}
}
?>