New ldaptive search executor search executor.

@param baseDn           the base dn
@param filterQuery      the filter query
@param params           the params
@param returnAttributes the return attributes
@return the search executor
976632
public static SearchExecutor newLdaptiveSearchExecutor(final String baseDn, final String filterQuery,
                                                           final List<String> params,
                                                           final String[] returnAttributes) {
        val executor = new SearchExecutor();
        executor.setBaseDn(baseDn);
        executor.setSearchFilter(newLdaptiveSearchFilter(filterQuery, params));
        executor.setReturnAttributes(returnAttributes);
        executor.setSearchScope(SearchScope.SUBTREE);
        return executor;
    }
1255819
@Override
    public <T> TypedQuery<T> createQuery(CriteriaQuery<T> paramCriteriaQuery)
    {
        checkClosed();

        return this.createQuery(CriteriaQueryTranslator.translate(paramCriteriaQuery),
                paramCriteriaQuery.getResultType());
    }
81657
public boolean search(final String dn,
                        final String filter,
                        final int scope) throws NamingException {
    if (debug()) {
      debug("Ldif: About to open " + dn);
    }

    inp = null;
    try {
      this.in = new FileInputStream(dn);
    } catch (final Throwable t) {
      throw new NamingException(t.getMessage());
    }
    return true;
  }
423000
private void convertToTermsQuery(FilterJoinNode node) {
    Map<String, Object> parent = node.getParentSourceMap();
    FilterJoinTerms terms = node.getTerms();
    BytesRef bytes = terms.getEncodedTerms();

    // Remove the filter join from the parent
    parent.remove(FilterJoinBuilder.NAME);

    // Create the nested object for the parameters of the field data terms query
    Map<String, Object> queryParams = new HashMap<>();
    queryParams.put("value", bytes.bytes);
    // use the hash of the filter join source map as cache key - see #170
    queryParams.put("_cache_key", node.getCacheId());

    // Create the nested object for the field
    Map<String, Object> field = new HashMap<>();
    field.put(node.getField(), queryParams);

    // Create the nested object for the field data terms query
    Map<String, Object> termsQuery = new HashMap<>();
    // If bytes terms encoding is used, we switch to the terms enum based terms query
    if (node.getTermsEncoding().equals(TermsByQueryRequest.TermsEncoding.BYTES)) {
      termsQuery.put(TermsEnumTermsQueryParser.NAME, field);
    }
    else {
      termsQuery.put(FieldDataTermsQueryParser.NAME, field);
    }

    // Create the object for the constant score query
    Map<String, Object> constantScoreQueryParams = new HashMap<>();
    constantScoreQueryParams.put("filter", termsQuery);

    // Add the constant score query to the parent
    parent.put(ConstantScoreQueryParser.NAME, constantScoreQueryParams);
    node.setState(FilterJoinNode.State.CONVERTED);
    this.blockingQueue.poll();
  }
163536
def _base_query(self, session):
        
        return session.query(ORMTargetMarker) \
            .filter(ORMTargetMarker.name == self.name) \
            .filter(ORMTargetMarker.params == self.params)
437270
protected function filterAttribute(
        EAVQueryBuilderInterface $eavQb,
        AttributeQueryBuilderInterface $attributeQueryBuilder,
        $value,
        $strategy = null,
        string $operationName = null
    ) {
        switch ($strategy) {
            case null:
            case BaseSearchFilter::STRATEGY_EXACT:
                $value = trim($value, '%');
                break;
            case BaseSearchFilter::STRATEGY_PARTIAL:
                $value = '%'.trim($value, '%').'%';
                break;
            case BaseSearchFilter::STRATEGY_START:
                $value = trim($value, '%').'%';
                break;
            case BaseSearchFilter::STRATEGY_END:
                $value = '%'.trim($value, '%');
                break;
            case BaseSearchFilter::STRATEGY_WORD_START:
                $value = '%'.trim($value, '%').'%'; // No, we are not going to implement this
                break;
            default:
                throw new InvalidArgumentException("strategy {$strategy} does not exist.");
        }

        return $attributeQueryBuilder->like($value);
    }
317400
public function setQuery($query, $baseDn)
    {
        $this->query = $query;
        $this->baseDn = $baseDn;

        $this->message = "No LDAP query results for filter: [{$query}] in: [{$baseDn}]";

        return $this;
    }
629288
def ldap_search(self, filter, attributes, incremental, incremental_filter):
        
        for uri in self.conf_LDAP_SYNC_BIND_URI:
            #Read record of this uri
            if (self.working_uri == uri):
                adldap_sync = self.working_adldap_sync
                created = False
            else:
                adldap_sync, created = ADldap_Sync.objects.get_or_create(ldap_sync_uri=uri)

            if ((adldap_sync.syncs_to_full > 0) and incremental):
                filter_to_use = incremental_filter.replace('?', self.whenchanged.strftime(self.conf_LDAP_SYNC_INCREMENTAL_TIMESTAMPFORMAT))
                logger.debug("Using an incremental search. Filter is:'%s'" % filter_to_use)
            else:
                filter_to_use = filter

            ldap.set_option(ldap.OPT_REFERRALS, 0)
            #ldap.set_option(ldap.OPT_NETWORK_TIMEOUT, 10)
            l = PagedLDAPObject(uri)
            l.protocol_version = 3

            if (uri.startswith('ldaps:')):
                l.set_option(ldap.OPT_X_TLS, ldap.OPT_X_TLS_DEMAND)
                l.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_DEMAND)
                l.set_option(ldap.OPT_X_TLS_DEMAND, True)
            else:
                l.set_option(ldap.OPT_X_TLS, ldap.OPT_X_TLS_NEVER)
                l.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
                l.set_option(ldap.OPT_X_TLS_DEMAND, False)
            try:
                l.simple_bind_s(self.conf_LDAP_SYNC_BIND_DN, self.conf_LDAP_SYNC_BIND_PASS)
            except ldap.LDAPError as e:
                logger.error("Error connecting to LDAP server %s : %s" % (uri, e))
                continue

            results = l.paged_search_ext_s(self.conf_LDAP_SYNC_BIND_SEARCH, ldap.SCOPE_SUBTREE, filter_to_use, attrlist=attributes, serverctrls=None)
            l.unbind_s()
            if (self.working_uri is None):
                self.working_uri = uri
                self.conf_LDAP_SYNC_BIND_URI.insert(0, uri)
                self.working_adldap_sync = adldap_sync

            return (uri, results)  # Return both the LDAP server URI used and the request. This is for incremental sync purposes
        #if not connected correctly, raise error
        raise
971150
def _formatFilterQuery(self, request=None, featureSets=[]):
        
        query = self._baseQuery()
        filters = []
        if issubclass(request.__class__,
                      protocol.SearchGenotypePhenotypeRequest):
            filters += self._filterSearchGenotypePhenotypeRequest(
                request, featureSets)

        if issubclass(request.__class__, protocol.SearchPhenotypesRequest):
            filters += self._filterSearchPhenotypesRequest(request)

        # apply filters
        filter = "FILTER ({})".format(' && '.join(filters))
        if len(filters) == 0:
            filter = ""
        query = query.replace("#%FILTER%", filter)
        return query
1254682
public <ResultT> CoreRemoteFindIterable<ResultT> find(
      final Bson filter,
      final Class<ResultT> resultClass
  ) {
    return createFindIterable(filter, resultClass);
  }
1121564
private Response<SearchResult> searchForServiceById(final Long id) throws LdapException {
        val filter = LdapUtils.newLdaptiveSearchFilter(this.searchFilter,
            LdapUtils.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME, CollectionUtils.wrap(id.toString()));
        return LdapUtils.executeSearchOperation(this.connectionFactory, this.baseDn, filter);
    }
215265
@When("^I search in LDAP using the filter '(.+?)' and the baseDn '(.+?)'$")
    public void searchLDAP(String filter, String baseDn) throws Exception {
        this.commonspec.setPreviousLdapResults(commonspec.getLdapUtils().search(new SearchRequest(baseDn, filter)));
    }
1207876
private NamingEnumeration search(String base, String filter,
                                     String[] returnAttrs)
        throws NamingException {

        SearchControls constraints = new SearchControls();
        constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
        constraints.setReturningAttributes(returnAttrs);

        // search the directory based on base, filter, and contraints
        //logger.debug("searching, base: " + base + " using filter: " + filter);
        DirContext dirContext = context();
        // get established jndi connection
        return dirContext.search(base, filter, constraints);
    }
804685
public JSONObject searchRules(RuleQuery query, RequestOptions requestOptions) throws AlgoliaException, JSONException {
    JSONObject body = new JSONObject();
    if (query.getQuery() != null) {
      body = body.put("query", query.getQuery());
    }
    if (query.getAnchoring() != null) {
      body = body.put("anchoring", query.getAnchoring());
    }
    if (query.getContext() != null) {
      body = body.put("context", query.getContext());
    }
    if (query.getPage() != null) {
      body = body.put("page", query.getPage());
    }
    if (query.getHitsPerPage() != null) {
      body = body.put("hitsPerPage", query.getHitsPerPage());
    }

    return client.postRequest("/1/indexes/" + encodedIndexName + "/rules/search", body.toString(), false, true, requestOptions);
  }
984110
protected void addSearchFilterCondition(
        CmsSelectQuery select,
        TableAlias users,
        CmsUserSearchParameters searchParams) {

        String searchFilter = searchParams.getSearchFilter();
        if (!CmsStringUtil.isEmptyOrWhitespaceOnly(searchFilter)) {
            boolean caseInsensitive = !searchParams.isCaseSensitive();
            if (caseInsensitive) {
                searchFilter = searchFilter.toLowerCase();
            }
            CmsCompositeQueryFragment searchCondition = new CmsCompositeQueryFragment();
            searchCondition.setSeparator(" OR ");
            searchCondition.setPrefix("(");
            searchCondition.setSuffix(")");
            //use coalesce in case any of the name columns are null
            String patternExprTemplate = generateConcat(
                "COALESCE(%1$s, '')",
                "' '",
                "COALESCE(%2$s, '')",
                "' '",
                "COALESCE(%3$s, '')");
            patternExprTemplate = wrapLower(patternExprTemplate, caseInsensitive);

            String patternExpr = String.format(
                patternExprTemplate,
                users.column(colName()),
                users.column(colFirstName()),
                users.column(colLastName()));
            String like = " LIKE ? ESCAPE '!' ";
            String matchExpr = patternExpr + like;
            searchFilter = "%" + CmsEncoder.escapeSqlLikePattern(searchFilter, '!') + '%';
            searchCondition.add(new CmsSimpleQueryFragment(matchExpr, searchFilter));
            for (SearchKey key : searchParams.getSearchKeys()) {
                switch (key) {
                    case email:
                        searchCondition.add(
                            new CmsSimpleQueryFragment(
                                wrapLower(users.column(colEmail()), caseInsensitive) + like,
                                searchFilter));
                        break;
                    case orgUnit:
                        searchCondition.add(new CmsSimpleQueryFragment(
                            wrapLower(users.column(colOu()), caseInsensitive) + like,
                            searchFilter));
                        break;
                    default:
                        break;
                }
            }
            select.addCondition(searchCondition);
        }
    }
838158
public <T> List<T> search(Class<T> managedClass, Name base, String filter, SearchControls scope) {
        Filter searchFilter = null;
        if(StringUtils.hasText(filter)) {
            searchFilter = new HardcodedFilter(filter);
        }

        return ldapTemplate.find(base, searchFilter, scope, managedClass);
    }
948567
public boolean search(String base, String filter) throws NamingException {
    return search(base, filter, scopeSub);
  }