newUser.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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. *
  8. * @author Roan Embrechts
  9. *
  10. * @package chamilo.auth.ldap
  11. */
  12. /**
  13. * when a user does not exist yet in dokeos,
  14. * but he or she does exist in the LDAP,
  15. * we add him to the dokeos database.
  16. */
  17. //require_once('../../inc/global.inc.php'); - this script should be loaded by the /index.php script anyway, so global is already loaded
  18. require_once 'authldap.php';
  19. $ldap_login_success = ldap_login($login, $password);
  20. if ($ldap_login_success) {
  21. //error_log('Found user '.$login.' on LDAP server',0);
  22. /*
  23. In here, we know that
  24. - the user does not exist in dokeos
  25. - the users login and password are correct
  26. */
  27. $info_array = ldap_find_user_info($login);
  28. ldap_put_user_info_locally($login, $info_array);
  29. } else {
  30. //error_log('Could not find '.$login.' on LDAP server',0);
  31. $loginFailed = true;
  32. unset($_user['user_id']);
  33. $uidReset = false;
  34. }