LdapTools\Utilities\ConverterUtilitiesTrait::getCurrentLdapAttributeValue PHP Метод

getCurrentLdapAttributeValue() защищенный Метод

This can be called to retrieve the current value of an attribute from LDAP.
protected getCurrentLdapAttributeValue ( string $attribute ) : array | string | null
$attribute string The attribute name to query for a value from the converter context
Результат array | string | null
    protected function getCurrentLdapAttributeValue($attribute)
    {
        if (!$this->getDn() || !$this->getLdapConnection()) {
            throw new AttributeConverterException(sprintf('Unable to query for the current "%s" attribute.', $attribute));
        }
        $query = new LdapQueryBuilder($this->getLdapConnection());
        try {
            return $query->select($attribute)->where($query->filter()->present('objectClass'))->setBaseDn($this->getDn())->setScopeBase()->getLdapQuery()->getSingleScalarOrNullResult();
        } catch (EmptyResultException $e) {
            throw new AttributeConverterException(sprintf('Unable to find LDAP object: %s', $this->getDn()));
        }
    }