Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / auth / ldap / auth_ldap_sync_users.php
blob2e29140b68a6ec424137bd83b29edc302bb32e7b
1 <?php
2 /** auth_ldap_sync_users.php
4 * This script is meant to be called from a cronjob to sync moodle with the LDAP
5 * backend in those setups where the LDAP backend acts as 'master'.
7 * Recommended cron entry:
8 * # 5 minutes past 4am
9 * 5 4 * * * /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/ldap/auth_ldap_sync_users.php
11 * Notes:
12 * - If you have a large number of users, you may want to raise the memory limits
13 * by passing -d momory_limit=256M
14 * - For debugging & better logging, you are encouraged to use in the command line:
15 * -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
17 * Performance notes:
18 * We have optimized it as best as we could for Postgres and mySQL, with 27K students
19 * we have seen this take 10 minutes.
24 if (isset($_SERVER['REMOTE_ADDR'])) {
25 error_log("should not be called from web server!");
26 exit;
29 $nomoodlecookie = true; // cookie not needed
31 require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
33 require_once($CFG->libdir.'/blocklib.php');
34 require_once($CFG->dirroot.'/course/lib.php');
35 require_once($CFG->dirroot.'/mod/resource/lib.php');
36 require_once($CFG->dirroot.'/mod/forum/lib.php');
38 if (!is_enabled_auth('ldap')) {
39 echo "Plugin not enabled!";
40 die;
43 $ldapauth = get_auth_plugin('ldap');
44 $ldapauth->sync_users(1000, true);