From 6bf7e8bcf2c4795508dc183e35e86de9947952c7 Mon Sep 17 00:00:00 2001 From: Omar Ramos Date: Sun, 14 Mar 2021 16:24:36 -0700 Subject: [PATCH] Moving strip domains loop to run before the connections loop. --- functions.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/functions.php b/functions.php index b0c1339..8b5bcaf 100644 --- a/functions.php +++ b/functions.php @@ -32,6 +32,15 @@ function authenticateUser() { try { global $connections, $domains_to_strip_automatically; + // Strip specific organization email domains if provided: + if (isset($domains_to_strip_automatically)) { + foreach($domains_to_strip_automatically as $domain) { + $domain = '@'.str_replace('@', '', $domain); + logMessage('Attempting to strip ' . $domain . ' from provided username.'); + $data['username'] = str_replace($domain, '', $data['username']); + } + } + foreach($connections as $connectionName => $connection) { logMessage('Before connection attempt to ' . $connectionName); @@ -43,15 +52,6 @@ function authenticateUser() { $organizationalUnit = $baseDn; - // Strip specific organization email domains if provided: - if (isset($domains_to_strip_automatically)) { - foreach($domains_to_strip_automatically as $domain) { - $domain = '@'.str_replace('@', '', $domain); - logMessage('Attempting to strip ' . $domain . ' from provided username.'); - $data['username'] = str_replace($domain, '', $data['username']); - } - } - $user = $connection->query() ->in($organizationalUnit) ->where('samaccountname', '=', $data['username'])