diff --git a/CHANGES.md b/CHANGES.md index 198cb862c09316ca6940e4f63a8b7171596777f1..6955c97ca6f8d00323db953f938b0e94b812cbb0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,10 @@ moodle-auth_ldap_syncplus Changes ------- +### Unreleased + +* 2017-03-03 - Adopt code changes in Moodle 3.2 core auth_ldap + ### v3.2-r1 * 2017-01-13 - Check compatibility for Moodle 3.2, no functionality change diff --git a/auth.php b/auth.php index ff5e8cb917aa23b14f26f9b26bd9e0ea82f1c0dc..a1176c8acc89886605c8c01305126797690bf271 100644 --- a/auth.php +++ b/auth.php @@ -96,7 +96,7 @@ class auth_plugin_ldap_syncplus extends auth_plugin_ldap { array_push($contexts, $this->config->create_context); } - $ldap_pagedresults = ldap_paged_results_supported($this->config->ldap_version); + $ldap_pagedresults = ldap_paged_results_supported($this->config->ldap_version, $ldapconnection); $ldap_cookie = ''; foreach ($contexts as $context) { $context = trim($context); diff --git a/config.html b/config.html index bd0d78ccf8cf6fa635212f6be9d078542ab306c2..78ec176d15ac82287f8623ba97f279be75bb4ce5 100644 --- a/config.html +++ b/config.html @@ -123,9 +123,31 @@ $fastpathoptions = array(AUTH_NTLM_FASTPATH_YESFORM => get_string('auth_ntlmsso_ AUTH_NTLM_FASTPATH_ATTEMPT => get_string('auth_ntlmsso_ie_fastpath_attempt', 'auth_ldap')); $disabled = ''; -if (!ldap_paged_results_supported($config->ldap_version)) { +$pagedresultssupported = false; +if ($config->host_url !== '') { + /** + * We try to connect each and every time we open the config, because we want to set the Page + * Size setting as enabled or disabled depending on the configured LDAP server supporting + * pagination or not, and to notify the user about it. If the user changed the LDAP server (or + * the LDAP protocol version) last time, it might happen that paged results are no longer + * available and we want to show that to the user the next time she goes to the settings page. + */ + try { + $ldapconn = $this->ldap_connect(); + $pagedresultssupported = ldap_paged_results_supported($config->ldap_version, $ldapconn); + } catch (Exception $e) { + // If we couldn't connect and get the supported options, we can only assume we don't support paged results. + $pagedresultssupported = false; + } +} +/* Make sure we only disable the paged result size setting and show the notification about it if + * there is a configured server that we tried to contact. Othersiwe, if someone's LDAP server does + * support paged results, they won't be able to turn it on the first time they set it up (because + * the field will be disabled). + */ +if (($config->host_url !== '') && (!$pagedresultssupported)) { $disabled = ' disabled="disabled"'; - echo $OUTPUT->notification(get_string('pagedresultsnotsupp', 'auth_ldap')); + echo $OUTPUT->notification(get_string('pagedresultsnotsupp', 'auth_ldap'), \core\output\notification::NOTIFY_INFO); } ?>