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