Skip to content

Commit

Permalink
Moving strip domains loop to run before the connections loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
orware committed Mar 14, 2021
1 parent 9009b31 commit 6bf7e8b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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'])
Expand Down

0 comments on commit 6bf7e8b

Please sign in to comment.