Thanks ixalmida - I tried yours and couldn't get it to work. Then i tried to water my down to something minimal:
<?php
if( isset($_POST['login']) && isset($_POST['password']) )
{
//LDAP stuff here.
$username = trim($_POST['login']);
$password = trim($_POST['password']);
$ldaphost = "ldap.server.edu";
$ds = ldap_connect($ldaphost);
$search = ldap_search($ds, "ou=x,dc=x,dc=x", "uid=$username");
$info = ldap_get_entries($ds, $search);
//Now, try to rebind with their full dn and password.
$bind = @ldap_bind($ds, $info[0][dn]);
if( !$bind || !isset($bind))
{
echo "Login failed -- please try again. (Debug 4)";
redirect("login.php");
include 'footer.php';
exit;
}
else
{
echo "Login WORKED. MAYBE." ;
exit;
}
exit;
}
?>
Two things I have noticed:
1) the first statement that basically says to do this script if there is something in both the username and password field isn't working. I'm putting in just a username, and it runs the script.
2) The bind I have is just completely ignoring the password field. I even remove the $password from it and it works. Does the bind statement not require a password to work? Seems that way.
I would like to do yours, but I don't completely understand how. When you have this:
$login = $username."@mydomain.com";
You want me just to use the domain name, not the ldap address? I'm sorry, I know little about LDAP and not sure how my network login @mydomain.com will resolve to LDAP.
Thanks again for your assistance!