LdapTools\Operation\Handler\QueryOperationHandler::getBaseDn PHP Method

getBaseDn() protected method

Gets the base DN for a search based off of the config and then the RootDSE.
protected getBaseDn ( ) : string
return string
    protected function getBaseDn()
    {
        if (!empty($this->connection->getConfig()->getBaseDn())) {
            $baseDn = $this->connection->getConfig()->getBaseDn();
        } elseif ($this->connection->getRootDse()->has('defaultNamingContext')) {
            $baseDn = $this->connection->getRootDse()->get('defaultNamingContext');
        } elseif ($this->connection->getRootDse()->has('namingContexts')) {
            $baseDn = $this->connection->getRootDse()->get('namingContexts')[0];
        } else {
            throw new LdapConnectionException('The base DN is not defined and could not be found in the RootDSE.');
        }
        return $baseDn;
    }