private void PathInsertedHandler(Node lastNodeInPath, TrackingAuthorityKind authorityKind) { RecipientTrackingEvent recipientTrackingEvent = (RecipientTrackingEvent)lastNodeInPath.Value; if (!string.IsNullOrEmpty(this.recipientPathFilter) && this.recipientPathFilter.Equals(recipientTrackingEvent.RecipientAddress.ToString(), StringComparison.OrdinalIgnoreCase)) { if (!this.hasRecipPathMatch) { TraceWrapper.SearchLibraryTracer.TraceDebug <SmtpAddress>(this.GetHashCode(), "Clearing queue because last event in path with recipient {0} matches recipient path fitler.", recipientTrackingEvent.RecipientAddress); this.referralQueue.Clear(); } this.hasRecipPathMatch = true; } else if (this.hasRecipPathMatch) { return; } if (this.IsRemoteEventPotentialReferral(recipientTrackingEvent, authorityKind)) { TraceWrapper.SearchLibraryTracer.TraceDebug <SmtpAddress, string>(this.GetHashCode(), "Getting authority for possible referral {0}, Original recip event={1}.", recipientTrackingEvent.RecipientAddress, Names <EventDescription> .Map[(int)recipientTrackingEvent.EventDescription]); TrackingAuthority trackingAuthority = this.getAuthorityAndRemapReferral(ref recipientTrackingEvent); TraceWrapper.SearchLibraryTracer.TraceDebug <string, string>(this.GetHashCode(), "Got authority {0}, Recip event is now {1}.", (trackingAuthority == null) ? "null" : Names <TrackingAuthorityKind> .Map[(int)trackingAuthority.TrackingAuthorityKind], Names <EventDescription> .Map[(int)recipientTrackingEvent.EventDescription]); if (trackingAuthority != null && !this.IsOutOfScopeTransfer(recipientTrackingEvent)) { TraceWrapper.SearchLibraryTracer.TraceDebug <SmtpAddress, string>(this.GetHashCode(), "Adding last event in path to referral queue address is {0}, the authority to follow is {1}.", recipientTrackingEvent.RecipientAddress, Names <TrackingAuthorityKind> .Map[(int)trackingAuthority.TrackingAuthorityKind]); this.referralQueue.Enqueue(new ReferralQueue.ReferralData { Node = lastNodeInPath, Authority = trackingAuthority }); } } }
public void Evaluate(IEnumerable <List <RecipientTrackingEvent> > initialEvents, TrackingAuthorityKind authorityKind) { this.InsertPaths(null, initialEvents, authorityKind); ReferralQueue.ReferralData referralData; while (this.referralQueue.DeQueue(out referralData)) { if (!this.directoryContext.TrackingBudget.IsUnderBudget()) { TraceWrapper.SearchLibraryTracer.TraceError(this.GetHashCode(), "Over budget following referrals, stopping", new object[0]); return; } Node node = referralData.Node; if (node.HasChildren) { TraceWrapper.SearchLibraryTracer.TraceDebug(this.GetHashCode(), "Skipping referral, node already has child.", new object[0]); } else { this.referralsFollowed++; if (this.referralsFollowed > 5000) { TraceWrapper.SearchLibraryTracer.TraceError <int>(this.GetHashCode(), "Processed {0} referrals. Giving up.", this.referralsFollowed); return; } ReferralQueue referralQueue = this.referralQueue; ReferralQueue.State state2 = new ReferralQueue.State(); state2.AuthorityKey = referralData.Authority.ToString(); state2.WorkerState = referralData; state2.WorkerMethod = delegate(object state) { ReferralQueue.ReferralData referralData2 = (ReferralQueue.ReferralData)state; Node node2 = referralData2.Node; TrackingAuthority authority = referralData2.Authority; RecipientTrackingEvent recipientTrackingEvent = (RecipientTrackingEvent)referralData2.Node.Value; IEnumerable <List <RecipientTrackingEvent> > paths; if (this.tryProcessReferral(recipientTrackingEvent, authority, out paths)) { TraceWrapper.SearchLibraryTracer.TraceDebug <SmtpAddress, string>(this.GetHashCode(), "Inserting paths after following referral for recipient {0} from {1}.", recipientTrackingEvent.RecipientAddress, Names <TrackingAuthorityKind> .Map[(int)authority.TrackingAuthorityKind]); this.InsertPaths(node2, paths, authority.TrackingAuthorityKind); return; } TraceWrapper.SearchLibraryTracer.TraceError <SmtpAddress>(this.GetHashCode(), "Did not get any results for referral to recipient {0}.", recipientTrackingEvent.RecipientAddress); }; referralQueue.BeginWorker(state2); } } }
public TrackingAuthority FindUserLocation(TrackedUser user) { TraceWrapper.SearchLibraryTracer.TraceDebug <SmtpAddress>(this.GetHashCode(), "Trying to get location for user: {0}", user.SmtpAddress); if (!user.IsMailbox) { bool flag = false; TrackingAuthority trackingAuthority = this.FindLocationByDomainAndServer(user.SmtpAddress.Domain, string.Empty, user.SmtpAddress, true, out flag); TraceWrapper.SearchLibraryTracer.TraceDebug <string>(this.GetHashCode(), "Looked up non-mailbox user via domain part. Authority for user is {0}", Names <TrackingAuthorityKind> .Map[(int)trackingAuthority.TrackingAuthorityKind]); return(trackingAuthority); } ServerInfo userServer = ServerCache.Instance.GetUserServer(user.ADUser); if (ServerStatus.LegacyExchangeServer == userServer.Status) { TraceWrapper.SearchLibraryTracer.TraceDebug <ADUser>(this.GetHashCode(), "Legacy server found for user: {0}", user.ADUser); return(LegacyExchangeServerTrackingAuthority.Instance); } if (ServerStatus.NotFound == userServer.Status) { TraceWrapper.SearchLibraryTracer.TraceError <ADUser>(this.GetHashCode(), "Server not found for user: {0}", user.ADUser); return(LegacyExchangeServerTrackingAuthority.Instance); } if (!userServer.IsSearchable) { TraceWrapper.SearchLibraryTracer.TraceError <ServerInfo>(this.GetHashCode(), "Server {0} is not searchable", userServer); return(LegacyExchangeServerTrackingAuthority.Instance); } if (userServer.ServerSiteId == null) { TraceWrapper.SearchLibraryTracer.TraceError <ADUser>(this.GetHashCode(), "Null siteId for user: {0}", user.ADUser); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "Site attribute was missing for user's {0} server {1}", new object[] { user.ADUser.Id, userServer.Key }); } if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MessageTracking.UseBackEndLocator.Enabled) { return(this.GetAuthorityForSiteUser(userServer.ServerSiteId, user.ADUser)); } return(this.GetAuthorityForSite(userServer.ServerSiteId)); }
public IList <TrackingAuthority> GetAuthoritiesByPriority(TrackedUser user) { List <TrackingAuthority> list = new List <TrackingAuthority>(5); if (!user.IsMailbox) { TraceWrapper.SearchLibraryTracer.TraceDebug(this.GetHashCode(), "User not a mailbox, using regular FindUserLocation", new object[0]); TrackingAuthority item = this.FindUserLocation(user); list.Add(item); return(list); } ServerInfo userServer = ServerCache.Instance.GetUserServer(user.ADUser); if (!userServer.IsSearchable) { TraceWrapper.SearchLibraryTracer.TraceDebug(this.GetHashCode(), "User server is legacy, using regular FindUserLocation", new object[0]); TrackingAuthority item2 = this.FindUserLocation(user); list.Add(item2); return(list); } ADObjectId serverSiteId = userServer.ServerSiteId; Dictionary <ADObjectId, IList <ServerInfo> > userMailboxLocationsBySite = this.GetUserMailboxLocationsBySite(user.ADUser); IList <ServerInfo> list2 = null; if (!userMailboxLocationsBySite.TryGetValue(serverSiteId, out list2)) { TraceWrapper.SearchLibraryTracer.TraceError <SmtpAddress>(this.GetHashCode(), "Unexpected: no authorities for user: {0}", user.SmtpAddress); return(list); } int num = user.IsArbitrationMailbox ? Constants.E14SP1ModerationReferralSupportVersion : Globals.E14Version; TrackingAuthority trackingAuthority; if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MessageTracking.UseBackEndLocator.Enabled) { trackingAuthority = this.GetAuthorityForSiteUser(serverSiteId, user.ADUser); } else { trackingAuthority = this.GetAuthorityForSite(serverSiteId, num); } if (trackingAuthority == null) { TraceWrapper.SearchLibraryTracer.TraceError <ADObjectId, int>(this.GetHashCode(), "No authority found for primary mailbox site {0} with minVersion {1}", serverSiteId, num); } else { list.Add(trackingAuthority); } userMailboxLocationsBySite.Remove(serverSiteId); foreach (KeyValuePair <ADObjectId, IList <ServerInfo> > keyValuePair in userMailboxLocationsBySite) { trackingAuthority = this.GetAuthorityForSite(keyValuePair.Key, num); if (trackingAuthority == null) { TraceWrapper.SearchLibraryTracer.TraceError <ADObjectId, int>(this.GetHashCode(), "No authority found for DAG mailbox site {0} with minVersion {1}", serverSiteId, num); break; } list.Add(trackingAuthority); } return(list); }
internal FindParameters(string messageId, RecipientTrackingEvent referralEvent, TrackingAuthority authority) { this.MessageId = messageId; this.ReferralEvent = referralEvent; this.Authority = authority; }