newUser.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php # $Id: newUser.php 14965 2008-04-20 23:01:17Z yannoo $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos SPRL
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Roan Embrechts
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  17. Mail: info@dokeos.com
  18. ==============================================================================
  19. */
  20. /**
  21. ==============================================================================
  22. * Users trying to login, who do not yet exist in the Dokeos database,
  23. * can be added by this script which tries to retrieve ldap information about
  24. * them.
  25. *
  26. * @author Roan Embrechts
  27. * @package dokeos.auth.ldap
  28. ==============================================================================
  29. */
  30. /*
  31. ==================================================
  32. when a user does not exist yet in dokeos,
  33. but he or she does exist in the LDAP,
  34. we add him to the dokeos database
  35. ==================================================
  36. */
  37. //require_once('../../inc/global.inc.php'); - this script should be loaded by the /index.php script anyway, so global is already loaded
  38. require_once('authldap.php');
  39. //error_log('Trying to register new user '.$login.' with pass '.$password,0);
  40. $ldap_login_success = ldap_login($login, $password);
  41. if ($ldap_login_success)
  42. {
  43. //error_log('Found user '.$login.' on LDAP server',0);
  44. /*
  45. In here, we know that
  46. - the user does not exist in dokeos
  47. - the users login and password are correct
  48. */
  49. $info_array = ldap_find_user_info($login);
  50. ldap_put_user_info_locally($login, $info_array);
  51. }
  52. else
  53. {
  54. //error_log('Could not find '.$login.' on LDAP server',0);
  55. $loginFailed = true;
  56. unset($_user['user_id']);
  57. $uidReset = false;
  58. }
  59. ?>