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:
9 * 5 4 * * * /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/ldap/auth_ldap_sync_users.php
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
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!");
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!";
43 $ldapauth = get_auth_plugin('ldap');
44 $ldapauth->sync_users(1000, true);