Reputation: 479
I'm trying to connect to my AD server and check if username and password is correct when I'm trying to do that, it always tells me:
Unable to bind to server: Invalid credentials
My code is:
$ldapconn = ldap_connect($adserver,$adport);
$ldapbind = @ldap_bind($ldapconn,"$username","$password");
When I tried to set a username with and without domain name in this variations: [email protected] domain\user user
When I'm trying to bind anonymously, Its ok. Do you have any suggestion here?
Upvotes: 2
Views: 4926
Reputation: 81
If you use Active directory then you must set this options:
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0);
and use FULL DN (ex. uid=UserName,cn=Peoples,dc=example,dc=com) or short version ([email protected]) AD supports both types.
Upvotes: 1
Reputation: 75496
Check username. It should be a properly formatted RDN/DN. Special characters must be escaped.
It would help if you post the value of $username
.
Upvotes: 0