@@ -252,7 +252,7 @@ public function checkAuthViaLdap(string $username, string $password, string &$me
252252 $ this ->connection ->connect ();
253253 Container::addConnection ($ this ->connection );
254254
255- $ dispatcher = Container::getEventDispatcher ();
255+ $ dispatcher = Container::getDispatcher ();
256256
257257 // Listen for failed authentication event
258258 $ dispatcher ->listen (Failed::class, function (Failed $ event ) use (&$ message ) {
@@ -297,7 +297,12 @@ public function checkAuthViaLdap(string $username, string $password, string &$me
297297 }
298298
299299 if (!$ success ) {
300- $ this ->di ->get (LoggerAuthProvider::SERVICE_NAME )->warning ("LDAP authentication {$ username } failed: {$ message }" );
300+ // WorkerApiCommands DI doesn't register loggerAuth; fall back to syslog there.
301+ if ($ this ->di ->has (LoggerAuthProvider::SERVICE_NAME )) {
302+ $ this ->di ->get (LoggerAuthProvider::SERVICE_NAME )->warning ("LDAP authentication {$ username } failed: {$ message }" );
303+ } else {
304+ \MikoPBX \Core \System \SystemMessages::sysLogMsg ('web_auth ' , "LDAP authentication {$ username } failed: {$ message }" , LOG_WARNING );
305+ }
301306 }
302307
303308 return $ success ;
@@ -390,7 +395,7 @@ public function getUsersList(): AnswerStructure
390395 $ this ->connection ->connect ();
391396 Container::addConnection ($ this ->connection );
392397
393- $ dispatcher = Container::getEventDispatcher ();
398+ $ dispatcher = Container::getDispatcher ();
394399 $ dispatcher ->listen (Failed::class, function (Failed $ event ) use (&$ message ) {
395400 $ ldap = $ event ->getConnection ();
396401 $ message = $ ldap ->getDiagnosticMessage ();
0 commit comments