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()));
}
}