diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index 6dbf68d..52c96f0 100644 --- a/auth/ldap/auth.php +++ b/auth/ldap/auth.php @@ -1543,8 +1543,8 @@ class auth_plugin_ldap extends auth_plugin_base { $connresult = ldap_connect($server); //ldap_connect returns ALWAYS true - if (!empty($this->config->version)) { - ldap_set_option($connresult, LDAP_OPT_PROTOCOL_VERSION, $this->config->version); + if (!empty($this->config->ldapversion)) { + ldap_set_option($connresult, LDAP_OPT_PROTOCOL_VERSION, $this->config->ldapversion); } // Fix MDL-10921 @@ -1995,8 +1995,8 @@ class auth_plugin_ldap extends auth_plugin_base { {$config->bind_dn = ''; } if (!isset($config->bind_pw)) {$config->bind_pw = ''; } - if (!isset($config->version)) - {$config->version = '2'; } + if (!isset($config->ldapversion)) + {$config->ldapversion = '2'; } if (!isset($config->objectclass)) {$config->objectclass = ''; } if (!isset($config->memberattribute)) @@ -2048,7 +2048,7 @@ class auth_plugin_ldap extends auth_plugin_base { set_config('preventpassindb', $config->preventpassindb, 'auth/ldap'); set_config('bind_dn', $config->bind_dn, 'auth/ldap'); set_config('bind_pw', $config->bind_pw, 'auth/ldap'); - set_config('version', $config->version, 'auth/ldap'); + set_config('ldapversion', $config->ldapversion, 'auth/ldap'); set_config('objectclass', trim($config->objectclass), 'auth/ldap'); set_config('memberattribute', $config->memberattribute, 'auth/ldap'); set_config('memberattribute_isdn', $config->memberattribute_isdn, 'auth/ldap'); diff --git a/auth/ldap/config.html b/auth/ldap/config.html index cb9ee66..ef56e5b 100644 --- a/auth/ldap/config.html +++ b/auth/ldap/config.html @@ -21,8 +21,8 @@ {$config->bind_dn = ''; } if (!isset($config->bind_pw)) {$config->bind_pw = ''; } - if (!isset($config->version)) - {$config->version = '2'; } + if (!isset($config->ldapversion)) + {$config->ldapversion = '2'; } if (!isset($config->objectclass)) {$config->objectclass = ''; } if (!isset($config->memberattribute)) @@ -95,8 +95,8 @@ if (!function_exists('ldap_connect')) { // Is php4-ldap really there? $versions = array(); $versions[2] = '2'; $versions[3] = '3'; - echo html_writer::select($versions, 'version', $config->version, false); - if (isset($err['version'])) echo $OUTPUT->error_text($err['version']); + echo html_writer::select($versions, 'ldapversion', $config->ldapversion, false); + if (isset($err['ldapversion'])) echo $OUTPUT->error_text($err['ldapversion']); ?> diff --git a/auth/ldap/db/install.php b/auth/ldap/db/install.php index f508bf8..16fa485 100644 --- a/auth/ldap/db/install.php +++ b/auth/ldap/db/install.php @@ -10,4 +10,17 @@ function xmldb_auth_ldap_install() { $DB->set_field('user', 'password', 'not cached', array('auth'=>'ldap')); } + // We kept the LDAP version used to connect to the server in + // $config->version. In 2.0, $config->version is overwritten with + // the plugin version number, so we need to change the setting + // name. Let's call it 'ldapversion' and remove the old setting. + // + // This works by pure luck, as the plugin version number is stored in + // config_plugins table before we get called. The good news is the new + // version number is stored for 'auth_ldap' plugin name, while the old ldap + // version setting is stored for 'auth/ldap' plugin name. Yay! + if ($ldapversion = get_config('auth/ldap', 'version')) { + set_config('ldapversion', $ldapversion, 'auth/ldap'); + unset_config('version', 'auth/ldap'); + } }