Skip to content

Commit

Permalink
MDL-16168 auth/cas CAS crashes if no LDAP is set up
Browse files Browse the repository at this point in the history
Pending fix for Moodle 2.x. Credit goes to Ivan Dackiewicz.
  • Loading branch information
iarenaza committed Jun 8, 2011
1 parent dba2410 commit beb807e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
37 changes: 36 additions & 1 deletion auth/cas/auth.php
Expand Up @@ -360,7 +360,7 @@ function process_config($config) {
* @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;
}

Expand Down Expand Up @@ -405,4 +405,39 @@ function iscreator($username) {

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);
}
}
1 change: 1 addition & 0 deletions auth/cas/lang/en/auth_cas.php
Expand Up @@ -61,4 +61,5 @@
$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)';

0 comments on commit beb807e

Please sign in to comment.