ldap - PHP - ldap_bind returns invalid credentials -


i trying make login page authenticate using ldap server. use following information , works ldap client.

host: ldap.med.xxx.edu port: 389 protocol: v3 base dn: ou=som,dc=med,dc=xxx,dc=edu security level: user + password user dn: med\myusername password: mypassword 

and have following code:

function ldap_authentication($uname, $password) {     $ldaprdn = "uid=med\\$uname,ou=som,dc=med,dc=xxx,dc=edu";     $ldappass = "$password";     ldap_set_option(null, ldap_opt_debug_level, 7);     $ldapconn = @ldap_connect("ldap.med.xxx.edu",389) or die("cannot connect 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, $ldappass);         if($ldapbind)         {             return "success...";         }         else         {              return "failed bind..." . ldap_error($ldapconn);         }     }     else {         return "cannot connect";     }     return "unknown error..."; } 

now php code returns "failed bind...invalid credenitials"

any idea doing wrong here?

i think have use either samaccountname=$uname,ou=som,dc=med,dc=xxx,dc=edu or med\\$uname bind.

the last 1 special activedirectory feature. first 1 takes account unique id on ad named samaccountname , not uid


Comments