Skip to content

Instantly share code, notes, and snippets.

@iarenaza
Created May 6, 2023 20:24
Show Gist options
  • Save iarenaza/07dda369970b025d5d8735da5be9c049 to your computer and use it in GitHub Desktop.
Save iarenaza/07dda369970b025d5d8735da5be9c049 to your computer and use it in GitHub Desktop.
diff --git a/auth/db/auth.php b/auth/db/auth.php
index bb9ed70363d..a1026c466d2 100644
--- a/auth/db/auth.php
+++ b/auth/db/auth.php
@@ -85,7 +85,7 @@ class auth_plugin_db extends auth_plugin_base {
$rs = $authdb->Execute("SELECT *
FROM {$this->config->table}
- WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."'");
+ WHERE LOWER({$this->config->fielduser}) = '".$this->ext_addslashes($extusername)."'");
if (!$rs) {
$authdb->Close();
debugging(get_string('auth_dbcantconnect','auth_db'));
@@ -113,7 +113,7 @@ class auth_plugin_db extends auth_plugin_base {
$rs = $authdb->Execute("SELECT {$this->config->fieldpass}
FROM {$this->config->table}
- WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."'");
+ WHERE LOWER({$this->config->fielduser}) = '".$this->ext_addslashes($extusername)."'");
if (!$rs) {
$authdb->Close();
debugging(get_string('auth_dbcantconnect','auth_db'));
@@ -226,7 +226,7 @@ class auth_plugin_db extends auth_plugin_base {
$select = implode(', ', $select);
$sql = "SELECT $select
FROM {$this->config->table}
- WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."'";
+ WHERE LOWER({$this->config->fielduser}) = '".$this->ext_addslashes($extusername)."'";
if ($rs = $authdb->Execute($sql)) {
if (!$rs->EOF) {
@@ -499,7 +499,7 @@ class auth_plugin_db extends auth_plugin_base {
$rs = $authdb->Execute("SELECT *
FROM {$this->config->table}
- WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."' ");
+ WHERE LOWER({$this->config->fielduser}) = '".$this->ext_addslashes($extusername)."' ");
if (!$rs) {
throw new \moodle_exception('auth_dbcantconnect', 'auth_db');
@@ -605,7 +605,7 @@ class auth_plugin_db extends auth_plugin_base {
if (!empty($update)) {
$sql = "UPDATE {$this->config->table}
SET ".implode(',', $update)."
- WHERE {$this->config->fielduser} = ?";
+ WHERE LOWER({$this->config->fielduser}) = ?";
if (!$authdb->Execute($sql, array($this->ext_addslashes($extusername)))) {
throw new \moodle_exception('auth_dbupdateerror', 'auth_db');
}
@@ -750,7 +750,7 @@ class auth_plugin_db extends auth_plugin_base {
$rs = $adodb->Execute("SELECT *
FROM {$this->config->table}
- WHERE {$this->config->fielduser} <> 'random_unlikely_username'"); // Any unlikely name is ok here.
+ WHERE LOWER({$this->config->fielduser}) <> 'random_unlikely_username'"); // Any unlikely name is ok here.
if (!$rs) {
echo $OUTPUT->notification(get_string('auth_dbcannotreadtable', 'auth_db'), 'notifyproblem');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment