Skip to content

Commit

Permalink
auth/ldap MDL-23418 LDAP version setting reset to version 2
Browse files Browse the repository at this point in the history
As authentication and enrolment plugins now have a version number, the LDAP
version number setting was "shadowed" by the plugin version number. So we
rename the LDAP setting name to ldap_version, et voila!
  • Loading branch information
iarenaza committed Jul 21, 2010
1 parent bd803ac commit 8dcf888
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
10 changes: 5 additions & 5 deletions auth/ldap/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -1543,8 +1543,8 @@ function ldap_connect($binddn='',$bindpwd='') {
$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->ldap_version)) {
ldap_set_option($connresult, LDAP_OPT_PROTOCOL_VERSION, $this->config->ldap_version);
}

// Fix MDL-10921
Expand Down Expand Up @@ -1995,8 +1995,8 @@ function process_config($config) {
{$config->bind_dn = ''; }
if (!isset($config->bind_pw))
{$config->bind_pw = ''; }
if (!isset($config->version))
{$config->version = '2'; }
if (!isset($config->ldap_version))
{$config->ldap_version = '2'; }
if (!isset($config->objectclass))
{$config->objectclass = ''; }
if (!isset($config->memberattribute))
Expand Down Expand Up @@ -2048,7 +2048,7 @@ function process_config($config) {
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('ldap_version', $config->ldap_version, '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');
Expand Down
8 changes: 4 additions & 4 deletions auth/ldap/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -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->ldap_version))
{$config->ldap_version = '2'; }
if (!isset($config->objectclass))
{$config->objectclass = ''; }
if (!isset($config->memberattribute))
Expand Down Expand Up @@ -95,8 +95,8 @@ <h4><?php print_string('auth_ldap_server_settings', 'auth_ldap') ?> </h4>
$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, 'ldap_version', $config->ldap_version, false);
if (isset($err['ldap_version'])) echo $OUTPUT->error_text($err['ldap_version']);
?>
</td>
<td>
Expand Down
13 changes: 13 additions & 0 deletions auth/ldap/db/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 'ldap_version' 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 ($ldap_version = get_config('auth/ldap', 'version')) {
set_config('ldap_version', $ldap_version, 'auth/ldap');
unset_config('version', 'auth/ldap');
}
}

0 comments on commit 8dcf888

Please sign in to comment.