diff --git a/auth/cas/auth.php b/auth/cas/auth.php index 5690c53d757..5283e883baa 100644 --- a/auth/cas/auth.php +++ b/auth/cas/auth.php @@ -360,7 +360,7 @@ class auth_plugin_cas extends auth_plugin_ldap { * @return boolean result */ function iscreator($username) { - if ((empty($this->config->attrcreators) && empty($this->config->groupecreators)) or empty($this->config->memberattribute)) { + if (empty($this->config->host_url) or (empty($this->config->attrcreators) && empty($this->config->groupecreators)) or empty($this->config->memberattribute)) { return false; } @@ -405,4 +405,39 @@ class auth_plugin_cas extends auth_plugin_ldap { return false; } + + /** + * Reads user information from LDAP and returns it as array() + * + * If no LDAP servers are configured, user information has to be + * provided via other methods (CSV file, manually, etc.). Return + * an empty array so existing user info is not lost. Otherwise, + * calls parent class method to get user info. + * + * @param string $username username + * @return mixed array with no magic quotes or false on error + */ + function get_userinfo($username) { + if (empty($this->config->host_url)) { + return array(); + } + return parent::get_userinfo($username); + } + + /** + * Syncronizes users from LDAP server to moodle user table. + * + * If no LDAP servers are configured, simply return. Otherwise, + * call parent class method to do the work. + * + * @param bool $do_updates will do pull in data updates from LDAP if relevant + * @return nothing + */ + function sync_users($do_updates=true) { + if (empty($this->config->host_url)) { + error_log('[AUTH CAS] '.get_string('noldapserver', 'auth_cas')); + return; + } + parent::sync_users($do_updates); + } } diff --git a/auth/cas/lang/en/auth_cas.php b/auth/cas/lang/en/auth_cas.php index 319a505164f..3f5fe1e2621 100644 --- a/auth/cas/lang/en/auth_cas.php +++ b/auth/cas/lang/en/auth_cas.php @@ -61,4 +61,5 @@ $string['auth_cas_text'] = 'Secure connection'; $string['auth_cas_use_cas'] = 'Use CAS'; $string['auth_cas_version'] = 'Version of CAS'; $string['CASform'] = 'Authentication choice'; +$string['noldapserver'] = 'No LDAP server configured for CAS! Syncing disabled.'; $string['pluginname'] = 'CAS server (SSO)';