public function getConnection($domain = null)
    {
        $domain = $domain ?: $this->context;
        $this->validateDomainName($domain);

        if (!$this->connections[$domain]) {
            $this->connections[$domain] = new LdapConnection(
                $this->domains[$domain],
                $this->config->getEventDispatcher(),
                $this->config->getLogger(),
                $this->getCache()
            );
        }

        return $this->connections[$domain];
    }