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 }); } } }
internal void InsertPaths(Node referralNode, TrackingAuthorityKind authorityKind, IEnumerable <List <RecipientTrackingEvent> > paths) { Dictionary <string, List <Node> > dictionary = new Dictionary <string, List <Node> >(); foreach (IList <RecipientTrackingEvent> list in paths) { Node[] array = new Node[list.Count]; for (int i = 0; i < list.Count; i++) { string text = list[i].RecipientAddress.ToString(); string parentKey = (i == 0) ? list[i].RootAddress : text; array[i] = new Node(text, parentKey, list[i].Clone()); if (i != 0) { array[i - 1].AddChild(array[i]); } } List <Node> list2; if (!dictionary.TryGetValue(array[0].ParentKey, out list2)) { list2 = new List <Node>(); dictionary.Add(array[0].ParentKey, list2); } list2.Add(array[0]); } foreach (string text2 in dictionary.Keys) { base.InsertAllChildrenForOneNode(text2, dictionary[text2], (Node parentNode, Node childNode) => this.Root == parentNode || parentNode == referralNode, (Node parent, Node child) => this.DoPostInsertionProcessing(parent, child, authorityKind)); } }
private RemoteTrustedOrgTrackingAuthority(string domain, TrackingAuthorityKind responsibleTracker, SmtpAddress proxyRecipient) : base(responsibleTracker, null) { if (string.IsNullOrEmpty(domain) && SmtpAddress.Empty.Equals(proxyRecipient)) { throw new ArgumentException("Either domain or proxyRecipient must be supplied, otherwise we cannot autodiscover the remote trusted organization"); } this.domain = domain; this.ProxyRecipient = proxyRecipient; }
private Node DoPostInsertionProcessing(Node parent, Node child, TrackingAuthorityKind authorityKind) { this.ApplyInheritance(parent, child); Node node = child; while (node.HasChildren) { if (node.Children.Count != 1) { throw new InvalidOperationException(string.Format("Unexpected number of child nodes ({0}) in referral tree", node.Children.Count)); } this.ApplyInheritance(node, node.Children[0]); node = node.Children[0]; } this.pathInsertedHandler(node, authorityKind); return(node); }
public void GetTimeBudgetRemainingForWSCall(TrackingAuthorityKind authorityKindToConnect, out TimeSpan clientTimeout, out TimeSpan serverTimeout) { TrackingAuthorityKindInformation trackingAuthorityKindInformation; if (EnumAttributeInfo <TrackingAuthorityKind, TrackingAuthorityKindInformation> .TryGetValue((int)authorityKindToConnect, out trackingAuthorityKindInformation)) { int expectedConnectionLatencyMSec = trackingAuthorityKindInformation.ExpectedConnectionLatencyMSec; } int num = (int)Math.Min(this.timer.Elapsed.TotalMilliseconds, 2147483647.0); if (this.timeBudgetAllowed.TotalMilliseconds <= (double)num) { TraceWrapper.SearchLibraryTracer.TraceError <double, int>(this.GetHashCode(), "No time budget remaining. Total budget: {0}, Already used up: {1}", this.timeBudgetAllowed.TotalMilliseconds, num); clientTimeout = TimeSpan.Zero; serverTimeout = TimeSpan.Zero; return; } double val = this.timeBudgetAllowed.TotalMilliseconds - (double)num; int num2 = (int)Math.Min(val, 2147483647.0); if (num2 <= trackingAuthorityKindInformation.ExpectedConnectionLatencyMSec) { TraceWrapper.SearchLibraryTracer.TraceError <int, string, int>(this.GetHashCode(), "Remaining time in budget = {0} is less than connection overhead for Connection-Type: {1}. Overhead = {2}", num2, Names <TrackingAuthorityKind> .Map[(int)authorityKindToConnect], trackingAuthorityKindInformation.ExpectedConnectionLatencyMSec); clientTimeout = TimeSpan.Zero; serverTimeout = TimeSpan.Zero; return; } int num3 = num2 - trackingAuthorityKindInformation.ExpectedConnectionLatencyMSec; clientTimeout = TimeSpan.FromMilliseconds((double)num2); serverTimeout = TimeSpan.FromMilliseconds((double)num3); TraceWrapper.SearchLibraryTracer.TraceError(this.GetHashCode(), "Timeouts calculated based on budget: clientTimeout={0}, serverTimeout={1}, elapsed={2}, total={3}", new object[] { num2, num3, num, this.timeBudgetAllowed.TotalMilliseconds }); }
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); } } }
private bool IsRemoteEventPotentialReferral(RecipientTrackingEvent recipientTrackingEvent, TrackingAuthorityKind authorityKindFollowed) { TraceWrapper.SearchLibraryTracer.TraceDebug <SmtpAddress, string>(this.GetHashCode(), "Evaluating referral for recipient: {0}, authority kind followed is: {1}", recipientTrackingEvent.RecipientAddress, Names <TrackingAuthorityKind> .Map[(int)authorityKindFollowed]); if (recipientTrackingEvent.EventDescription != EventDescription.SmtpSendCrossSite && recipientTrackingEvent.EventDescription != EventDescription.SmtpSendCrossForest && recipientTrackingEvent.EventDescription != EventDescription.TransferredToForeignOrg && recipientTrackingEvent.EventDescription != EventDescription.TransferredToPartnerOrg && recipientTrackingEvent.EventDescription != EventDescription.PendingModeration && recipientTrackingEvent.EventDescription != EventDescription.SubmittedCrossSite) { TraceWrapper.SearchLibraryTracer.TraceDebug <string>(this.GetHashCode(), "Event: {0} does not indicate a referral", Names <EventDescription> .Map[(int)recipientTrackingEvent.EventDescription]); return(false); } if (recipientTrackingEvent.EventDescription == EventDescription.PendingModeration && (authorityKindFollowed == TrackingAuthorityKind.RemoteForest || authorityKindFollowed == TrackingAuthorityKind.RemoteTrustedOrg)) { TraceWrapper.SearchLibraryTracer.TraceDebug <string>(this.GetHashCode(), "Pending moderation is not a referral for authority {0}.", Names <TrackingAuthorityKind> .Map[(int)authorityKindFollowed]); return(false); } if ((authorityKindFollowed == TrackingAuthorityKind.RemoteForest || authorityKindFollowed == TrackingAuthorityKind.RemoteTrustedOrg) && recipientTrackingEvent.EventDescription != EventDescription.SmtpSendCrossForest && recipientTrackingEvent.EventDescription != EventDescription.TransferredToForeignOrg && recipientTrackingEvent.EventDescription != EventDescription.TransferredToPartnerOrg) { TraceWrapper.SearchLibraryTracer.TraceDebug <string>(this.GetHashCode(), "Following {0} should result only in referrals to other orgs or forests.", Names <TrackingAuthorityKind> .Map[(int)authorityKindFollowed]); return(false); } return(true); }
private void InsertPaths(Node referralNode, IEnumerable <List <RecipientTrackingEvent> > paths, TrackingAuthorityKind authorityKind) { TraceWrapper.SearchLibraryTracer.TraceDebug <string>(this.GetHashCode(), "Inserting paths from referral for {0}", (referralNode != null) ? referralNode.Key : "<null>"); this.referralTree.InsertPaths(referralNode, authorityKind, this.FilterForPathsToInsert(referralNode, paths)); }
protected TrackingAuthority(TrackingAuthorityKind responsibleTracker) { this.trackingAuthorityKind = responsibleTracker; }
protected WebServiceTrackingAuthority(TrackingAuthorityKind responsibleTracker, Uri uri) : base(responsibleTracker) { this.uri = uri; }
protected ADAuthenticationTrackingAuthority(TrackingAuthorityKind responsibleTracker, Uri uri) : base(responsibleTracker, uri) { }
private RemoteSiteInCurrentOrgTrackingAuthority(string defaultDomain, TrackingAuthorityKind responsibleTracker, ADObjectId siteADObjectId, Uri casServerUri, int serverVersion) : base(responsibleTracker, casServerUri) { this.defaultDomain = defaultDomain; this.siteADObjectId = siteADObjectId; this.serverVersion = serverVersion; }