diff --git a/classes/feature/usersync/main.php b/classes/feature/usersync/main.php index 7efa11d37..f270bbff6 100644 --- a/classes/feature/usersync/main.php +++ b/classes/feature/usersync/main.php @@ -910,11 +910,9 @@ public function sync_users(array $aadusers = array()) { return true; } + $select = 'SELECT LOWER(u.username) AS username,'; if (isset($aadsync['emailsync'])) { - $select = 'SELECT LOWER(u.email) AS email, - LOWER(u.username) AS username,'; - } else { - $select = 'SELECT LOWER(u.username) AS username,'; + $select .= ' LOWER(u.email) AS email,'; } $sql = "$select