public function getLdapUser($attribute, $value)
    {
        try {
            $query = $this->ldap->buildLdapQuery()
                ->select($this->getAttributesToSelect())
                ->from($this->options['ldap_object_type'])
                ->where([$attribute => $value]);
            if (!is_null($this->options['search_base'])) {
                $query->setBaseDn($this->options['search_base']);
            }
            return $query->getLdapQuery()->getSingleResult();
        } catch (EmptyResultException $e) {
            throw new UsernameNotFoundException(sprintf('Username "%s" was not found.', $value));
        } catch (MultiResultException $e) {
            throw new UsernameNotFoundException(sprintf('Multiple results for "%s" were found.', $value));
        }
    }
public function getLdapUser($attribute, $value)
    {
        try {
            $query = $this->ldap->buildLdapQuery()
                ->select($this->getAttributesToSelect())
                ->from($this->options['ldap_object_type'])
                ->where([$attribute => $value]);
            if (!is_null($this->options['search_base'])) {
                $query->setBaseDn($this->options['search_base']);
            }
            return $query->getLdapQuery()->getSingleResult();
        } catch (EmptyResultException $e) {
            throw new UsernameNotFoundException(sprintf('Username "%s" was not found.', $value));
        } catch (MultiResultException $e) {
            throw new UsernameNotFoundException(sprintf('Multiple results for "%s" were found.', $value));
        }
    }
public function getLdapUser ( $ attribute , $ value ) { try { $ query = $ this -> ldap -> buildLdapQuery ( ) -> select ( $ this -> getAttributesToSelect ( ) ) -> from ( $ this -> options [ 'ldap_object_type' ] ) -> where ( [ $ attribute => $ value ] ) ; if ( ! is_null ( $ this -> options [ 'search_base' ] ) ) { $ query -> setBaseDn ( $ this -> options [ 'search_base' ] ) ; } return $ query -> getLdapQuery ( ) -> getSingleResult ( ) ; } catch ( EmptyResultException $ e ) { throw new UsernameNotFoundException ( sprintf ( 'Username "%s" was not found.' , $ value ) ) ; } catch ( MultiResultException $ e ) { throw new UsernameNotFoundException ( sprintf ( 'Multiple results for "%s" were found.' , $ value ) ) ; } }
Search for, and return, the LDAP user by a specific attribute.

@param string $attribute
@param string $value
@return LdapObject
Search for and return the LDAP user by a specific attribute .