login.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Users trying to login, who already exist in the Chamilo database
  5. * and have ldap as authentication type get verified here.
  6. * @author Roan Embrechts
  7. * @package chamilo.auth.ldap
  8. */
  9. /**
  10. * An external authentification module needs to set
  11. * - $loginFailed
  12. * - $uidReset
  13. * - $_user['user_id']
  14. * - register the $_user['user_id'] in the session
  15. *
  16. * As the LDAP code shows, this is not as difficult as you might think.
  17. * LDAP authentification module
  18. * this calls the loginWithLdap function
  19. * from the LDAP library, and sets a few
  20. * variables based on the result.
  21. */
  22. //require_once('../../inc/global.inc.php'); - this script should be loaded by the /index.php script anyway, so global is already loaded
  23. use ChamiloSession as Session;
  24. require_once('authldap.php');
  25. $loginLdapSucces = ldap_login($login, $password);
  26. if ($loginLdapSucces) {
  27. $loginFailed = false;
  28. $uidReset = true;
  29. $_user['user_id'] = $uData['user_id'];
  30. Session::write('_uid', $_uid);
  31. // Jand: copied from event_login in events.lib.php to enable login statistics:
  32. Event::event_login($uData['user_id']);
  33. } else {
  34. $loginFailed = true;
  35. unset($_user['user_id']);
  36. $uidReset = false;
  37. }