I've set up Active Directory and ADLDAP on Windows server 2012. I'm trying a simple ldap_bind but continue to have a "invalid credentials" error spit back to me.
In my AD Users and Groups screen, I clearly see the domain I made along with the OU (organizational unit) and users inside of it. ASDI Edit clearly tells me the DN for that user:
CN=Bob Smith,OU=Accounting,DC=mydomain,DC=net
Further, the BaseDN is clearly told to me in ASDI Edit because it's above the OU group "accounting" -
DC=mydomain,DC=net
Now onto my script - which throws no LDAP connect errors, only on bind, with a constant invalid credentials:
$connectionLDAP = "LDAP://localhost:54126";
$basedn = 'DC=mydomain,DC=net';
$ldap = ldap_connect($connectionLDAP) or die("Could not connect to LDAP server.");
$username = $post['username'];
$password = $post['password'];
$usernameForBind = "CN=".$username.",OU=Accounting,".$basedn;
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
$bind = ldap_bind($ldap, $usernameForBind, $password);
This spits the following warning, and of course my script ends there since there is no positive match to username and password found:
Warning: ldap_bind(): Unable to bind to server: Invalid credentials in C:\....\login.php on line 41
And the below error echos produce this:
echo(ldap_error($ldap)."<br>");
echo(ldap_errno($ldap)."<br>");
Invalid credentials
49
I have tried every combination of DN, username, email address, mydomain\username without the rest of the DN info, everything I can think of....but for the life of me it won't take, and google + Stack searches unfortunately aren't helping me at the moment get past this.
Thanks for any assistance.