LdapTools\AttributeConverter\ConvertValueToDn::getAttributeFromLdapQuery PHP Метод

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

Attempt to look-up the attribute from a LDAP query based on the value.
protected getAttributeFromLdapQuery ( string $value, string $toSelect ) : string
$value string
$toSelect string
Результат string The distinguished name.
    protected function getAttributeFromLdapQuery($value, $toSelect)
    {
        $options = $this->getOptionsArray();
        $query = $this->buildLdapQuery($options['filter'], isset($options['or_filter']) && $options['or_filter'], $toSelect);
        $bOr = $this->getQueryOrStatement($query, $value);
        $eq = $query->filter()->eq($options['attribute'], $value);
        if (!empty($bOr->getChildren())) {
            $bOr->add($eq);
            $query->where($bOr);
        } else {
            $query->where($eq);
        }
        if (isset($options['base_dn'])) {
            $query->setBaseDn($options['base_dn']);
        }
        try {
            return $query->getLdapQuery()->getSingleScalarResult();
        } catch (EmptyResultException $e) {
            throw new AttributeConverterException(sprintf('Unable to convert value "%s" to a %s for attribute "%s"', $value, $toSelect, $this->getAttribute()));
        }
    }