Skip to content

Commit 6bf7e8b

Browse files
committed
Moving strip domains loop to run before the connections loop.
1 parent 9009b31 commit 6bf7e8b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

functions.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ function authenticateUser() {
3232
try {
3333
global $connections, $domains_to_strip_automatically;
3434

35+
// Strip specific organization email domains if provided:
36+
if (isset($domains_to_strip_automatically)) {
37+
foreach($domains_to_strip_automatically as $domain) {
38+
$domain = '@'.str_replace('@', '', $domain);
39+
logMessage('Attempting to strip ' . $domain . ' from provided username.');
40+
$data['username'] = str_replace($domain, '', $data['username']);
41+
}
42+
}
43+
3544
foreach($connections as $connectionName => $connection) {
3645

3746
logMessage('Before connection attempt to ' . $connectionName);
@@ -43,15 +52,6 @@ function authenticateUser() {
4352

4453
$organizationalUnit = $baseDn;
4554

46-
// Strip specific organization email domains if provided:
47-
if (isset($domains_to_strip_automatically)) {
48-
foreach($domains_to_strip_automatically as $domain) {
49-
$domain = '@'.str_replace('@', '', $domain);
50-
logMessage('Attempting to strip ' . $domain . ' from provided username.');
51-
$data['username'] = str_replace($domain, '', $data['username']);
52-
}
53-
}
54-
5555
$user = $connection->query()
5656
->in($organizationalUnit)
5757
->where('samaccountname', '=', $data['username'])

0 commit comments

Comments
 (0)