Skip to content

Commit 6dea0be

Browse files
committed
Moving strip domains loop to run before the connections loop.
1 parent 879ac7f commit 6dea0be

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
@@ -29,6 +29,15 @@ function authenticateUser($data) {
2929
try {
3030
global $connections, $domains_to_strip_automatically;
3131

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

3443
logMessage('Before connection attempt to ' . $connectionName);
@@ -40,15 +49,6 @@ function authenticateUser($data) {
4049

4150
$organizationalUnit = $baseDn;
4251

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

0 commit comments

Comments
 (0)