From 9a688af4ee06a6386a8f59ec8225b711b5c8caef Mon Sep 17 00:00:00 2001 From: Inaki Date: Wed, 15 Sep 2010 16:18:52 +0000 Subject: [PATCH] auth/cas MDL-16168 CAS crashes if no LDAP is set up Don't crash if no LDAP server is configured. This also means that user details need to be retrieved/updated via other means. --- auth/cas/auth.php | 7 +++++++ lang/en_utf8/auth.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/auth/cas/auth.php b/auth/cas/auth.php index 8a058e8abd9..e396305cad4 100644 --- a/auth/cas/auth.php +++ b/auth/cas/auth.php @@ -370,6 +370,13 @@ if ( !is_object($PHPCAS_CLIENT) ) { * @return mixed array with no magic quotes or false on error */ function get_userinfo($username) { + // No LDAP servers configured, so user info has to be provided + // via other methods (CSV file, manually, etc.). Return empty + // array so existing user info is not lost. + if (empty($this->config->host_url)) { + return array(); + } + $textlib = textlib_get_instance(); $extusername = $textlib->convert(stripslashes($username), 'utf-8', $this->config->ldapencoding); $ldapconnection = $this->ldap_connect(); diff --git a/lang/en_utf8/auth.php b/lang/en_utf8/auth.php index d7562d4ef72..5c6184e2692 100644 --- a/lang/en_utf8/auth.php +++ b/lang/en_utf8/auth.php @@ -187,7 +187,7 @@ $string['auth_ldap_graceattr_desc'] = 'Optional: Overrides gracelogin attribute $string['auth_ldap_gracelogins_desc'] = 'Enable LDAP gracelogin support. After password has expired user can login until gracelogin count is 0. Enabling this setting displays grace login message if password is expired.'; $string['auth_ldap_groupecreators'] = 'List of groups or contexts whose members are allowed to create groups. Separate multiple groups with \';\'. Usually something like \'cn=teachers,ou=staff,o=myorg\''; $string['auth_ldap_groupecreators_key'] = 'Group creators'; -$string['auth_ldap_host_url'] = 'Specify LDAP host in URL-form like \'ldap://ldap.myorg.com/\' or \'ldaps://ldap.myorg.com/\' Separate multipleservers with \';\' to get failover support.'; +$string['auth_ldap_host_url'] = 'Specify LDAP host in URL-form like \'ldap://ldap.myorg.com/\' or \'ldaps://ldap.myorg.com/\' Separate multipleservers with \';\' to get failover support.

NOTE: If you do not set this value Moodle will not try to get/update user information from LDAP, but the locking of the fields you specify below will be respected.'; $string['auth_ldap_ldap_encoding'] = 'Specify encoding used by LDAP server. Most probably utf-8, MS AD v2 uses default platform encoding such as cp1252, cp1250, etc.'; $string['auth_ldap_login_settings'] = 'Login settings'; $string['auth_ldap_memberattribute'] = 'Optional: Overrides user member attribute, when users belongs to a group. Usually \'member\'';