newUser.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. //error_log('Trying to register new user '.$login.' with pass '.$password,0);
  18. $ldap_login_success = ldap_login($login, $password);
  19. if ($ldap_login_success)
  20. {
  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. }