public SearchWorkDefinition ParseSearch(ComplianceMessage target, SearchWorkDefinition definition) { QueryFilter queryFilter = null; string query = definition.Query; CultureInfo culture; FaultDefinition faultDefinition; ExceptionHandler.Parser.TryRun(delegate { if (string.IsNullOrEmpty(target.Culture)) { culture = CultureInfo.InvariantCulture; } else { culture = CultureInfo.GetCultureInfo(target.Culture); } Func <IRecipientResolver, IPolicyTagProvider, QueryFilter> func = null; switch (definition.Parser) { case SearchWorkDefinition.QueryParser.KQL: func = ((IRecipientResolver r, IPolicyTagProvider p) => KqlParser.ParseAndBuildQuery(query, KqlParser.ParseOption.EDiscoveryMode, culture, r, p)); break; case SearchWorkDefinition.QueryParser.AQS: func = delegate(IRecipientResolver r, IPolicyTagProvider p) { AqsParser.ParseOption parseOption = AqsParser.ParseOption.UseCiKeywordOnly | AqsParser.ParseOption.DisablePrefixMatch | AqsParser.ParseOption.AllowShortWildcards; return(AqsParser.ParseAndBuildQuery(query, parseOption, culture, r, p)); }; break; } if (func != null) { OrganizationId scopingOrganizationId = null; IPolicyTagProvider arg = null; IRecipientResolver arg2 = null; if (OrganizationId.TryCreateFromBytes(target.TenantId, Encoding.UTF8, out scopingOrganizationId)) { ADSessionSettings adsessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(scopingOrganizationId); adsessionSettings.IncludeInactiveMailbox = true; IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.PartiallyConsistent, adsessionSettings, 146, "ParseSearch", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\TaskDistributionSystem\\ApplicationPlugins\\EDiscovery\\FastLocalSearchResultsProvider.cs"); arg2 = new FastLocalSearchResultsProvider.RecipientIdentityResolver(tenantOrRootOrgRecipientSession); IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, adsessionSettings, 149, "ParseSearch", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\TaskDistributionSystem\\ApplicationPlugins\\EDiscovery\\FastLocalSearchResultsProvider.cs"); arg = new PolicyTagAdProvider(tenantOrTopologyConfigurationSession); } queryFilter = func(arg2, arg); } if (queryFilter != null) { definition.Query = FqlQueryBuilder.ToFqlString(queryFilter, culture); } }, TimeSpan.FromMinutes(1.0), out faultDefinition, target, null, default(CancellationToken), null, "ParseSearch", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\TaskDistributionSystem\\ApplicationPlugins\\EDiscovery\\FastLocalSearchResultsProvider.cs", 102); if (faultDefinition != null) { ExceptionHandler.FaultMessage(target, faultDefinition, true); } return(definition); }
internal void GenerateSubQueryFilters(IRecipientSession recipientSession, IConfigurationSession configurationSession) { if (!string.IsNullOrEmpty(this.userQuery)) { SearchMailboxCriteria.RecipientIdentityResolver recipientResolver = null; if (recipientSession != null) { recipientResolver = new SearchMailboxCriteria.RecipientIdentityResolver(recipientSession); } PolicyTagAdProvider policyTagProvider = null; if (configurationSession != null) { policyTagProvider = new PolicyTagAdProvider(configurationSession); } QueryFilter queryFilter = KqlParser.ParseAndBuildQuery(this.userQuery, KqlParser.ParseOption.ImplicitOr | KqlParser.ParseOption.UseCiKeywordOnly | KqlParser.ParseOption.DisablePrefixMatch | KqlParser.ParseOption.AllowShortWildcards | KqlParser.ParseOption.EDiscoveryMode, this.QueryCulture, RescopedAll.Default, recipientResolver, policyTagProvider); if (queryFilter == null) { throw new SearchQueryEmptyException(); } ICollection <QueryFilter> collection = null; if (queryFilter != null && queryFilter.GetType() == typeof(OrFilter)) { collection = AqsParser.FlattenQueryFilter(queryFilter); } if (collection != null && collection.Count > 1) { string text = this.searchQuery.Replace(this.userQuery, ""); QueryFilter queryFilter2 = null; if (!string.IsNullOrEmpty(text)) { queryFilter2 = KqlParser.ParseAndBuildQuery(text, KqlParser.ParseOption.ImplicitOr | KqlParser.ParseOption.UseCiKeywordOnly | KqlParser.ParseOption.DisablePrefixMatch | KqlParser.ParseOption.AllowShortWildcards | KqlParser.ParseOption.EDiscoveryMode, this.QueryCulture, RescopedAll.Default, recipientResolver, policyTagProvider); } this.subfilters = new Dictionary <string, QueryFilter>(collection.Count); int num = 0; foreach (QueryFilter queryFilter3 in collection) { string keywordPhrase = MailboxDiscoverySearch.GetKeywordPhrase(queryFilter3, this.userQuery, ref num); QueryFilter value; if (queryFilter2 == null) { value = queryFilter3; } else { value = new AndFilter(new QueryFilter[] { queryFilter2, queryFilter3 }); } if (!this.subfilters.ContainsKey(keywordPhrase)) { this.subfilters.Add(keywordPhrase, value); } } } } }
public bool ValidateKeywordsLimit() { if (!string.IsNullOrEmpty(this.SearchObject.CalculatedQuery) && this.SearchObject.CalculatedQuery != MailboxDiscoverySearch.EmptyQueryReplacement) { QueryFilter queryFilter = KqlParser.ParseAndBuildQuery(this.SearchObject.CalculatedQuery, KqlParser.ParseOption.ImplicitOr | KqlParser.ParseOption.UseCiKeywordOnly | KqlParser.ParseOption.DisablePrefixMatch | KqlParser.ParseOption.AllowShortWildcards | KqlParser.ParseOption.EDiscoveryMode, new CultureInfo(this.SearchObject.Language), RescopedAll.Default, null, null); if (queryFilter != null && queryFilter.Keywords() != null && (long)queryFilter.Keywords().Count <string>() > (long)((ulong)this.MaxQueryKeywords)) { return(false); } } return(true); }
internal static string ConvertAqsToKql(string aqsString, CultureInfo culture) { if (string.IsNullOrEmpty(aqsString)) { return(aqsString); } Exception ex = null; QueryFilter queryFilter = null; try { queryFilter = AqsParser.ParseAndBuildQuery(aqsString, AqsParser.ParseOption.UseCiKeywordOnly | AqsParser.ParseOption.DisablePrefixMatch | AqsParser.ParseOption.QueryConverting | AqsParser.ParseOption.AllowShortWildcards, culture, RescopedAll.Default, null, null); } catch (ParserException ex2) { ex = ex2; } if (queryFilter == null) { throw new MailboxSearchTaskException(Strings.CannotConvertAqsToKql(ex.Message ?? string.Empty)); } string text = null; ex = null; try { text = queryFilter.GenerateInfixString(FilterLanguage.Kql); QueryFilter aqsFilter = AqsParser.ParseAndBuildQuery(aqsString, AqsParser.ParseOption.UseCiKeywordOnly | AqsParser.ParseOption.DisablePrefixMatch | AqsParser.ParseOption.AllowShortWildcards, culture, RescopedAll.Default, null, null); QueryFilter kqlFilter = KqlParser.ParseAndBuildQuery(text, KqlParser.ParseOption.ImplicitOr | KqlParser.ParseOption.UseCiKeywordOnly | KqlParser.ParseOption.DisablePrefixMatch | KqlParser.ParseOption.AllowShortWildcards, culture, RescopedAll.Default, null, null); if (!Utils.VerifyQueryFilters(aqsFilter, kqlFilter)) { throw new MailboxSearchTaskException(Strings.CannotConvertAqsToKql(string.Empty)); } } catch (ParserException ex3) { ex = ex3; } catch (ArgumentOutOfRangeException ex4) { ex = ex4; } if (ex != null) { throw new MailboxSearchTaskException(Strings.CannotConvertAqsToKql(ex.Message)); } return(text); }
private QueryFilter GetQueryFilter(string queryString, IRecipientSession recipientSession, IConfigurationSession configurationSession, out QueryFilter nonDiscoveryQueryFilter) { SearchCriteria.RecipientIdentityResolver recipientResolver = null; if (recipientSession != null) { recipientResolver = new SearchCriteria.RecipientIdentityResolver(recipientSession); } PolicyTagAdProvider policyTagProvider = null; if (configurationSession != null) { policyTagProvider = new PolicyTagAdProvider(configurationSession); } KqlParser.ParseOption parseOption = KqlParser.ParseOption.ImplicitOr | KqlParser.ParseOption.UseCiKeywordOnly | KqlParser.ParseOption.DisablePrefixMatch | KqlParser.ParseOption.AllowShortWildcards; nonDiscoveryQueryFilter = KqlParser.ParseAndBuildQuery(queryString, parseOption, this.queryCulture, RescopedAll.Default, recipientResolver, policyTagProvider); parseOption |= KqlParser.ParseOption.EDiscoveryMode; return(KqlParser.ParseAndBuildQuery(queryString, parseOption, this.queryCulture, RescopedAll.Default, recipientResolver, policyTagProvider)); }
// Token: 0x06000161 RID: 353 RVA: 0x00009948 File Offset: 0x00007B48 public InPlaceHoldConfiguration(PolicyDefinitionConfig definition, PolicyRuleConfig rule, RuleParser parser, Trace tracer) { this.Name = definition.Name; this.Identity = ExMailboxComplianceItemContainer.GetHoldId(definition.Identity); this.Enabled = (definition.Mode == Mode.Enforce); this.IsValid = false; PolicyRule rule2 = parser.GetRule(rule.RuleBlob); if (rule2 != null) { this.QueryString = string.Empty; string text = KqlHelpers.GenerateHoldKeepQuery(rule2, ExPropertyNameMapping.Mapping); if (string.IsNullOrEmpty(text)) { this.QueryFilter = null; } else { this.QueryFilter = KqlParser.ParseAndBuildQuery(text, KqlParser.ParseOption.DisablePrefixMatch | KqlParser.ParseOption.AllowShortWildcards | KqlParser.ParseOption.EDiscoveryMode, CultureInfo.InvariantCulture, null, null); } this.IsValid = true; } }
internal void ResolveQueryFilter(IRecipientSession recipientSession, IConfigurationSession configurationSession) { SearchMailboxCriteria.RecipientIdentityResolver recipientResolver = null; if (recipientSession != null) { recipientResolver = new SearchMailboxCriteria.RecipientIdentityResolver(recipientSession); } PolicyTagAdProvider policyTagProvider = null; if (configurationSession != null) { policyTagProvider = new PolicyTagAdProvider(configurationSession); } if (this.SearchQuery != null) { this.searchFilter = KqlParser.ParseAndBuildQuery(this.SearchQuery, KqlParser.ParseOption.ImplicitOr | KqlParser.ParseOption.UseCiKeywordOnly | KqlParser.ParseOption.DisablePrefixMatch | KqlParser.ParseOption.AllowShortWildcards | KqlParser.ParseOption.EDiscoveryMode, this.QueryCulture, RescopedAll.Default, recipientResolver, policyTagProvider); if (this.searchFilter == null) { throw new SearchQueryEmptyException(); } } SearchMailboxCriteria.Tracer.TraceDebug <QueryFilter>((long)this.GetHashCode(), "SearchMailboxCriteria resolved QueryFilter:{0}", this.searchFilter); }