@@ -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