D'oh - counting $totalcount wrongly (duplicate courses are ignored)
[moodle-linuxchix.git] / auth / cas / auth_ldap_sync_users.php
blobe4caec4b45db13a9c1442278a0bece9b7fde7997
1 <?php
2 /** auth_ldap_sync_users.php
3 * Modified for cas Module
5 * This script is meant to be called from a cronjob to sync moodle with the LDAP
6 * backend in those setups where the LDAP backend acts as 'master'.
8 * Recommended cron entry:
9 * # 5 minutes past 4am
10 * 5 4 * * * /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/ldap/auth_ldap_sync_users.php
12 * Notes:
13 * - If you have a large number of users, you may want to raise the memory limits
14 * by passing -d momory_limit=256M
15 * - For debugging & better logging, you are encouraged to use in the command line:
16 * -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
18 * Performance notes:
19 * We have optimized it as best as we could for Postgres and mySQL, with 27K students
20 * we have seen this take 10 minutes.
25 if (isset($_SERVER['REMOTE_ADDR'])) {
26 error_log("should not be called from web server!");
27 exit;
30 $nomoodlecookie = true; // cookie not needed
32 require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
34 require_once($CFG->dirroot.'/course/lib.php');
35 require_once($CFG->dirroot.'/lib/blocklib.php');
36 require_once($CFG->dirroot.'/mod/resource/lib.php');
37 require_once($CFG->dirroot.'/mod/forum/lib.php');
38 require_once($CFG->dirroot.'/lib/moodlelib.php');
40 if (!is_enabled_auth('cas')) {
41 echo "Plugin not enabled!";
42 die;
45 $casauth = get_auth_plugin('cas');
46 $casauth->sync_users(1000, true);