newUser.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Users trying to login, who do not yet exist in the Chamilo database,
  5. * can be added by this script which tries to retrieve ldap information
  6. * about them.
  7. * @author Roan Embrechts
  8. * @package chamilo.auth.ldap
  9. */
  10. /**
  11. * when a user does not exist yet in dokeos,
  12. * but he or she does exist in the LDAP,
  13. * we add him to the dokeos database
  14. */
  15. //require_once('../../inc/global.inc.php'); - this script should be loaded by the /index.php script anyway, so global is already loaded
  16. require_once 'authldap.php';
  17. $ldap_login_success = ldap_login($login, $password);
  18. if ($ldap_login_success) {
  19. //error_log('Found user '.$login.' on LDAP server',0);
  20. /*
  21. In here, we know that
  22. - the user does not exist in dokeos
  23. - the users login and password are correct
  24. */
  25. $info_array = ldap_find_user_info($login);
  26. ldap_put_user_info_locally($login, $info_array);
  27. } else {
  28. //error_log('Could not find '.$login.' on LDAP server',0);
  29. $loginFailed = true;
  30. unset($_user['user_id']);
  31. $uidReset = false;
  32. }