Do the LDAP query to get the LDAP object.

@param bool $anonymous
@return \LdapTools\Object\LdapObject
767587
protected function doLdapQuery($anonymous)
    {
        if ($anonymous) {
            $this->connection->connect('', '', true);
        }
        $schema = $this->schemaFactory->get(self::SCHEMA_ROOTDSE_NAME, $this->connection->getConfig()->getLdapType());
        
        return (new LdapQueryBuilder($this->connection))->from($schema)->select('*')->getLdapQuery()->getSingleResult();
    }
221731
public function asObject($asObject = null)
    {
        if ($asObject === null)
        {
            return $this->_asObject;
        }
        $this->_asObject = $asObject;

        return $this;
    }
448948
public function setLdap(Zend_Ldap $ldap)
    {
        $this->_ldap = $ldap;

        $this->setOptions(array($ldap->getOptions()));

        return $this;
    }
485110
public function get($entityId)
    {
        $key = $this->getEntityDescriptor()->className();
        $key .= '::'.$entityId;
        $entity = $this->getIdentityMap()->get($key, false);
        if ($entity === false) {
            $entity = $this->load($entityId);
        }
        return $entity;
    }
663150
public function data($json = false)
    {
        return ($json) ? $this->container->getRequest()->data->JSON : $this->container->getRequest()->data;
    }
1122294
public static function getById($id, $asArray = false)
    {
        if (isset(self::$identityMap[$id])) {
            if (self::getIdentityMapMaxSize() !== -1) {
                $row = self::$identityMap[$id];
                unset(self::$identityMap[$id]);
                self::$identityMap[$id] = $row;
            }
            if ($asArray) {
                return self::$identityMap[$id];
            } else {
                $model = new static;
                /** @var ActiveRecord $modelClass */
                $modelClass = get_class($model);
                $modelClass::populateRecord($model, self::$identityMap[$id]);
                return $model;
            }
        } else {
            $row = static::find()
                ->where([static::getIdAttribute() => $id])
                ->asArray($asArray)
                ->one();
            static::addRowToMap($row);
            return $row;
        }
    }
1053214
public function dnStrToArr($dnStr, $excludeBaseDn = true, $includeAttributes = false)
    {
        if ($excludeBaseDn) {
            return ldap_explode_dn($dnStr, ($includeAttributes ? 0 : 1));
        } else {
            return ldap_explode_dn($this->adldap->getBaseDn().$dnStr, ($includeAttributes ? 0 : 1));
        }
    }
1194055
public function bind($username = null, $password = null, $nosub = 0)
	{
		if (!$this->isConnected())
		{
			if (!$this->connect())
			{
				return false;
			}
		}

		if ($username === null)
		{
			$username = $this->username;
		}

		if ($password === null)
		{
			$password = $this->password;
		}

		$this->setDn($username, $nosub);

		$this->isBound = ldap_bind($this->resource, $this->getDn(), $password);

		return $this->isBound;
	}
1187066
public function auth($auth = true)
    {
        $headers = $this->headers();
        if ($auth === false) {
            unset($headers['Authorization']);
        }
        if (!$auth) {
            return;
        }
        if (is_array($auth) && !empty($auth['nonce'])) {
            $data = ['method' => $this->method(), 'uri' => $this->path()];
            $data += $auth;
        } else {
            $data = [];
        }
        $auth = $this->_classes['auth'];
        $data = $auth::encode($this->username(), $this->password(), $data);
        $headers['Authorization'] = $auth::header($data);
        return $this;
    }
470547
public function newEntity($ldapObject)
    {
        $entity = $this->getEntity();
        if (isset($ldapObject['uid']['0'])) {
            $entity->setUsername($ldapObject['uid']['0']);
            $entity->setDisplayName($ldapObject['cn']['0']);
            $entity->setEmail($ldapObject['mail']['0']);
            $entity->setPassword(md5('HandledByLdap'));
            $entity->setRoles(serialize($this->getLdapRoles($ldapObject)));
        }
        return $entity;
    }
554206
public function get($id)
  {
    if (isset($this->instances[$id])) return $this->instances[$id];
    if (isset($this->callables[$id]))
    {
      $item = call_user_func($this->callables[$id],$this);
      return $this->instances[$id] = $item;
    }
    throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined for get.', $id));
  }
240234
public function getCredentialsFetcher()
    {
        $fetcher = null;

        if ($this->credentialsFetcher) {
            $fetcher = $this->credentialsFetcher;
        } elseif ($this->keyFile) {
            $fetcher = CredentialsLoader::makeCredentials($this->scopes, $this->keyFile);
        } else {
            try {
                $fetcher = $this->getADC();
            } catch (\DomainException $ex) {
                $fetcher = new AnonymousCredentials();
            }
        }

        return new FetchAuthTokenCache(
            $fetcher,
            $this->authCacheOptions,
            $this->authCache
        );
    }
747820
public function get($sessionId)
    {
        $result = $this->getConnection()->table('oauth_sessions')
                    ->where('oauth_sessions.id', $sessionId)
                    ->first();

        if (is_null($result)) {
            return;
        }

        return (new SessionEntity($this->getServer()))
               ->setId($result->id)
               ->setOwner($result->owner_type, $result->owner_id);
    }
761353
public function get($id)
    {
        if ($this->has($id) == false) {
            throw new ServiceNotFoundException($id); 
        } 

        if (\is_object($this->services[$id]) == false || method_exists($this->services[$id], '__invoke') == false) {
            return $this->services[$id];
        }
        $this->services[$id] = $this->services[$id]($this); 
    
        return $this->services[$id];
    }
528252
protected function getLdapUrl($server = null)
    {
        $server = $server ?: $this->serverPool->getServer();
        $ldapUrl = ($this->config->getUseSsl() ? 'ldaps' : 'ldap').'://'.$server.':'.$this->config->getPort();

        return [$ldapUrl, $server];
    }
913147
public function getEntriesAction($objectClass, $name)
    {
        $entries = [];
        $server = $this->ldap->get($name);
        $user = isset($server['user']) ? $server['user'] : null;
        $password = isset($server['password']) ? $server['password'] : null;

        if ($this->ldap->connect($server, $user, $password)) {
            if ($search = $this->ldap->search($this->ldap->get($name), '(&(objectClass='.$objectClass.'))')) {
                $entries = $this->ldap->getEntries($search);
            }

            $this->ldap->close();
        }

        return new Response(json_encode($entries));
    }
259890
public function connect(): self
    {
        $this->logger->debug('connect to ldap server ['.$this->uri.']', [
            'category' => get_class($this),
        ]);

        if (null === $this->binddn) {
            $this->logger->warning('no binddn set for ldap connection, you should avoid anonymous bind', [
                'category' => get_class($this),
            ]);
        }

        if (false === $this->tls && 'ldaps' !== substr($this->uri, 0, 5)) {
            $this->logger->warning('neither tls nor ldaps enabled for ldap connection, it is strongly reccommended to encrypt ldap connections', [
                'category' => get_class($this),
            ]);
        }

        $this->connection = ldap_connect($this->uri);

        foreach ($this->options as $opt => $value) {
            ldap_set_option($this->connection, constant($opt), $value);
        }

        if (true === $this->tls) {
            ldap_start_tls($this->connection);
        }

        if ($this->connection) {
            if (null !== $this->binddn) {
                $bind = ldap_bind($this->connection, $this->binddn, $this->bindpw);

                if ($bind) {
                    $this->logger->info('bind to ldap server ['.$this->uri.'] with binddn ['.$this->binddn.'] was succesful', [
                        'category' => get_class($this),
                    ]);

                    return $this;
                }

                throw new Exception('failed bind to ldap server, error: '.ldap_error($this->connection));
            }
        } else {
            throw new Exception('failed connect to ldap server '.$this->uri);
        }

        return $this;
    }