moodle/auth/ldap/auth_ldap_sync_users.php
Petr Skoda 9b56a34f7d MDL-16089 some resource lib and lang pack cleanup
AMOS START
 MOV [displayauto,mod_resource],[resourcedisplayauto,core]
 MOV [displaydownload,mod_resource],[resourcedisplaydownload,core]
 MOV [displayembed,mod_resource],[resourcedisplayembed,core]
 MOV [displayframe,mod_resource],[resourcedisplayframe,core]
 MOV [displaynew,mod_resource],[resourcedisplaynew,core]
 MOV [displayopen,mod_resource],[resourcedisplayopen,core]
 MOV [displaypopup,mod_resource],[resourcedisplaypopup,core]

AMOS END
2010-05-22 13:54:41 +00:00

44 lines
1.2 KiB
PHP
Executable File

<?php
/** auth_ldap_sync_users.php
*
* This script is meant to be called from a cronjob to sync moodle with the LDAP
* backend in those setups where the LDAP backend acts as 'master'.
*
* Recommended cron entry:
* # 5 minutes past 4am
* 5 4 * * * /usr/bin/php -c /etc/php4/cli/php.ini /var/www/moodle/auth/ldap/auth_ldap_sync_users.php
*
* Notes:
* - If you have a large number of users, you may want to raise the memory limits
* by passing -d momory_limit=256M
* - For debugging & better logging, you are encouraged to use in the command line:
* -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0
*
* Performance notes:
* We have optimized it as best as we could for Postgres and mySQL, with 27K students
* we have seen this take 10 minutes.
*
*/
if (isset($_SERVER['REMOTE_ADDR'])) {
error_log("should not be called from web server!");
exit;
}
define('NO_MOODLE_COOKIES', true);
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
require_once($CFG->dirroot.'/course/lib.php');
if (!is_enabled_auth('ldap')) {
echo "Plugin not enabled!";
die;
}
$ldapauth = get_auth_plugin('ldap');
$ldapauth->sync_users(true);