Guest User

Untitled

a guest
Sep 23rd, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. public function verifyLdapUser($username,$password)
  2. {
  3.  
  4. $DomainName=LDAPDOMAIN; // name = domain
  5. $ldap_server=LDAP; // server = ldap://doman.co
  6. // returns true when user/pass binds to LDAP/AD.
  7. $auth_user=$username."@".$DomainName;
  8.  
  9. //Check to see if LDAP module is loaded.
  10. if (extension_loaded('ldap')) {
  11.  
  12. if($connect=@ldap_connect($ldap_server)){
  13.  
  14. //echo "connection ($ldap_server): ";
  15. if($bind=@ldap_bind($connect, $auth_user, $password)){
  16.  
  17. //echo "true <BR>";
  18. @ldap_close($connect);
  19. return true;
  20. } else {
  21. //send error message - password incorrect
  22.  
  23. @ldap_close($connect);
  24. return false;
  25. }
  26. }
  27. } else {
  28. //send message - could not connect to domain
  29. @ldap_close($connect);
  30. return false;
  31. }
  32. // send message - ldap module not loaded
  33.  
  34. @ldap_close($connect);
  35. return(false);
  36. }//end function verifyLdapUser
Add Comment
Please, Sign In to add comment