I actually just implemented a basic LDAP authentication script. This was
my first draft of the script before I changed and messed with it to fit
with my setup. This basically connects to the server, if not the scrpt is
killed. Then tries to authenticate the given username and password, if not,
it fails. Quick and simple.
$ldapHost = "example2.com";
$ldapPort = 666;
$ldapBaseDn = "ldap base dn here";
$username = "username";
$password = "password";
$ldapUserDn = "uid=$username,".$ldapBaseDn;
echo "LDAP query test
echo "Connecting ...
$ldapConn = ldap_connect($ldapHost, $ldapPort)
or die("Unable to connect to LDAP server: $ldapHost
echo "Authenticating user ...
$isValid = ldap_bind($ldapConn, $ldapUserDn, $password)
or die("Unable to authenticate user: $username
echo "User $username is successfully authenticated!
echo "Closing connection ...