Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function verifyLdapUser($username,$password)
- {
- $DomainName=LDAPDOMAIN; // name = domain
- $ldap_server=LDAP; // server = ldap://doman.co
- // returns true when user/pass binds to LDAP/AD.
- $auth_user=$username."@".$DomainName;
- //Check to see if LDAP module is loaded.
- if (extension_loaded('ldap')) {
- if($connect=@ldap_connect($ldap_server)){
- //echo "connection ($ldap_server): ";
- if($bind=@ldap_bind($connect, $auth_user, $password)){
- //echo "true <BR>";
- @ldap_close($connect);
- return true;
- } else {
- //send error message - password incorrect
- @ldap_close($connect);
- return false;
- }
- }
- } else {
- //send message - could not connect to domain
- @ldap_close($connect);
- return false;
- }
- // send message - ldap module not loaded
- @ldap_close($connect);
- return(false);
- }//end function verifyLdapUser
Add Comment
Please, Sign In to add comment