Update existing LDAP instance configuration instead of replacing it. Caching was not enabled as per the configuration, so this fixes this.

This commit is contained in:
2025-04-26 21:31:00 +10:00
parent 808934ebfe
commit 3604f1498c
4 changed files with 7 additions and 30 deletions

View File

@@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Session;
use LdapRecord\Container;
use App\Ldap\Connection;
use App\Ldap\Guard;
class SwapinAuthUser
{
@@ -37,7 +37,11 @@ class SwapinAuthUser
}
// We need to override our Connection object so that we can store and retrieve the logged in user and swap out the credentials to use them.
Container::getInstance()->addConnection(new Connection(config('ldap.connections.'.$key)),$key);
$c = Container::getInstance()
->getConnection($key);
$c->setConfiguration(config('ldap.connections.'.$key));
$c->setGuardResolver(fn()=>new Guard($c->getLdapConnection(),$c->getConfiguration()));
return $next($request);
}