public override void Process(GetSearchableMailboxesInputs item) { Recorder.Trace(4L, TraceType.InfoTrace, new object[] { "InitializeGetSearchablebleMailbox.Process Item:", item, "Filter:", item.Filter, "ExpandGroups:", item.ExpandGroups }); SearchSource[] source = new SearchSource[] { new SearchSource { ReferenceId = item.Filter, SourceType = SourceType.AllMailboxes } }; DirectoryQueryParameters item2 = new DirectoryQueryParameters { ExpandPublicFolders = false, ExpandGroups = item.ExpandGroups, MatchRecipientsToSources = false, PageSize = (int)base.Policy.ExecutionSettings.DiscoveryDisplaySearchPageSize, Properties = SearchRecipient.DisplayProperties, RequestGroups = true, Sources = source.ToList <SearchSource>() }; base.Executor.EnqueueNext(item2); }
public IEnumerable <SearchRecipient> Query(ISearchPolicy policy, DirectoryQueryParameters request) { Recorder.Trace(5L, TraceType.InfoTrace, new object[] { "ActiveDirectoryProvider.Query Query:", request.Query, "PageSize:", request.PageSize, "Properties:", request.Properties, "ExpandGroups:", request.ExpandGroups }); ADPagedReader <ADRawEntry> pagedReader = policy.RecipientSession.FindPagedADRawEntry(null, QueryScope.SubTree, request.Query, null, request.PageSize, request.Properties); new List <SearchRecipient>(); foreach (ADRawEntry entry in pagedReader) { if (request.ExpandGroups && SearchRecipient.IsMembershipGroup(entry)) { Recorder.Trace(5L, TraceType.InfoTrace, "ActiveDirectoryProvider.Query Expanding:", entry); List <ADRawEntry> groupEntries = new List <ADRawEntry>(); ADRecipientExpansion expansion = new ADRecipientExpansion(policy.RecipientSession, false, request.Properties); ADRecipientExpansion.HandleRecipientDelegate handleDelegate = delegate(ADRawEntry recipient, ExpansionType recipientExpansionType, ADRawEntry parent, ExpansionType parentExpansionType) { if (recipientExpansionType == ExpansionType.GroupMembership) { return(ExpansionControl.Continue); } groupEntries.Add(recipient); return(ExpansionControl.Skip); }; ADRecipientExpansion.HandleFailureDelegate failureDelegate = delegate(ExpansionFailure expansionFailure, ADRawEntry recipient, ExpansionType recipientExpansionType, ADRawEntry parent, ExpansionType parentExpansionType) { Recorder.Trace(5L, TraceType.ErrorTrace, new object[] { "ActiveDirectoryProvider.Query Expansion Failed:", recipient, "Error:", expansionFailure, "ExpansionType:", recipientExpansionType, "Parent:", parent, "ParentyExpansionType:", parentExpansionType }); return(ExpansionControl.Skip); }; expansion.Expand(entry, handleDelegate, failureDelegate); foreach (ADRawEntry groupEntry in groupEntries) { yield return(new SearchRecipient(groupEntry, entry)); } } else { yield return(new SearchRecipient(entry, null)); } } yield break; }
public override void Process(SearchMailboxesInputs item) { Recorder.Trace(4L, TraceType.InfoTrace, "InitializeSearchMailbox.Process Item:", item); if (!item.IsLocalCall) { Recorder.Trace(4L, TraceType.InfoTrace, "InitializeSearchMailbox.Process ApplyConfiguration"); ISearchConfigurationProvider searchConfigurationProvider = SearchFactory.Current.GetSearchConfigurationProvider(base.Policy); searchConfigurationProvider.ApplyConfiguration(base.Policy, ref item); } CultureInfo culture = CultureInfo.InvariantCulture; if (!string.IsNullOrEmpty(item.Language)) { Recorder.Trace(4L, TraceType.InfoTrace, "InitializeSearchMailbox.Process Set Language:", item.Language); try { culture = new CultureInfo(item.Language); } catch (CultureNotFoundException) { Recorder.Trace(4L, TraceType.ErrorTrace, "InitializeSearchMailbox.Process Failed Language:", item.Language); throw new SearchException(KnownError.ErrorQueryLanguageNotValid); } } if (!string.IsNullOrWhiteSpace(item.SearchQuery)) { Recorder.Trace(4L, TraceType.InfoTrace, "InitializeSearchMailbox.Process Set Query:", item.SearchQuery); try { IConfigurationSession configurationSession = SearchFactory.Current.GetConfigurationSession(base.Policy); item.Criteria = new SearchCriteria(item.SearchQuery, null, culture, item.SearchType, base.Policy.RecipientSession, configurationSession, item.RequestId, base.Policy.ExecutionSettings.ExcludedFolders); goto IL_195; } catch (ParserException ex) { Recorder.Trace(4L, TraceType.ErrorTrace, new object[] { "InitializeSearchMailbox.Process Failed Query:", item.SearchQuery, "Error:", ex }); throw new SearchException(KnownError.ErrorInvalidSearchQuerySyntax, ex); } catch (TooManyKeywordsException ex2) { Recorder.Trace(4L, TraceType.ErrorTrace, new object[] { "InitializeSearchMailbox.Process Failed Query:", item.SearchQuery, "Error:", ex2 }); throw new SearchException(KnownError.TooManyKeywordsException, ex2); } goto IL_181; IL_195: if (item.Sources != null && item.Sources.Count > 0) { Recorder.Trace(4L, TraceType.ErrorTrace, "InitializeSearchMailbox.Process Source Count:", item.Sources.Count); if (item.Sources.Count > base.Policy.ExecutionSettings.DiscoveryMaxMailboxes && item.SearchType == SearchType.Preview) { Recorder.Trace(4L, TraceType.ErrorTrace, new object[] { "InitializeSearchMailbox.Process Source Failed Count:", item.Sources.Count, "Limit:", base.Policy.ThrottlingSettings.DiscoveryMaxMailboxes, "SearchType:", item.SearchType }); throw new SearchException(KnownError.TooManyMailboxesException, new object[] { item.Sources.Count, base.Policy.ExecutionSettings.DiscoveryMaxMailboxes }); } if ((long)item.Sources.Count > (long)((ulong)base.Policy.ThrottlingSettings.DiscoveryMaxStatsSearchMailboxes) && item.SearchType == SearchType.Statistics) { Recorder.Trace(4L, TraceType.ErrorTrace, new object[] { "InitializeSearchMailbox.Process Source Failed Count:", item.Sources.Count, "Limit:", base.Policy.ThrottlingSettings.DiscoveryMaxStatsSearchMailboxes, "SearchType:", item.SearchType }); throw new SearchException(KnownError.TooManyMailboxesException, new object[] { item.Sources.Count, (int)base.Policy.ThrottlingSettings.DiscoveryMaxStatsSearchMailboxes }); } if (!item.IsLocalCall) { Recorder.Trace(4L, TraceType.InfoTrace, "InitializeSearchMailbox.Process Format Query"); DirectoryQueryParameters item2 = new DirectoryQueryParameters { ExpandPublicFolders = true, ExpandGroups = true, MatchRecipientsToSources = true, Properties = SearchRecipient.SearchProperties, Sources = item.Sources, PageSize = (int)base.Policy.ExecutionSettings.DiscoveryADPageSize }; base.Executor.EnqueueNext(item2); return; } Recorder.Trace(4L, TraceType.InfoTrace, "InitializeSearchMailbox.Process Search Database"); using (List <SearchSource> .Enumerator enumerator = item.Sources.GetEnumerator()) { while (enumerator.MoveNext()) { SearchSource item3 = enumerator.Current; base.Executor.EnqueueNext(item3); } return; } } Recorder.Trace(4L, TraceType.ErrorTrace, "InitializeSearchMailbox.Process No Sources"); throw new SearchException(KnownError.ErrorNoMailboxSpecifiedForSearchOperation); } IL_181: Recorder.Trace(4L, TraceType.ErrorTrace, "InitializeSearchMailbox.Process Failed Query Empty"); throw new SearchException(KnownError.ErrorSearchQueryCannotBeEmpty); }