Security/LdapAuthenticationTrait.php
protected function switchDomainIfNeeded($domain)
    {
        if (!empty($domain) && $this->ldap->getDomainContext() !== $domain) {
            $this->ldap->switchDomain($domain);
        }
    }
protected function switchDomainIfNeeded($domain)
    {
        if (!empty($domain) && $this->ldap->getDomainContext() !== $domain) {
            $this->ldap->switchDomain($domain);
        }
    }
If the domain needs to a different context for the request, then switch it.

@param string|null $domain