private static OrganizationConfigCache.Item GetOrgSettings(IConfigurationSession tenantConfigSession, ref bool shouldAdd) { Organization orgContainer = tenantConfigSession.GetOrgContainer(); if (orgContainer == null) { TraceWrapper.SearchLibraryTracer.TraceError(0, "ADSystemConfigurationSession.GetOrgContainer returned null", new object[0]); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "msExchOrganizationContainer object not found", new object[0]); } bool readTrackingEnabled = orgContainer.ReadTrackingEnabled; QueryFilter filter = new NotFilter(new BitMaskAndFilter(AcceptedDomainSchema.AcceptedDomainFlags, 1UL)); ADPagedReader <AcceptedDomain> adpagedReader = tenantConfigSession.FindPaged <AcceptedDomain>(tenantConfigSession.GetOrgContainerId(), QueryScope.SubTree, filter, null, 0); HashSet <string> hashSet = new HashSet <string>(StringComparer.OrdinalIgnoreCase); HashSet <string> hashSet2 = new HashSet <string>(StringComparer.OrdinalIgnoreCase); string text = null; int num = 0; int num2 = 0; foreach (AcceptedDomain acceptedDomain in adpagedReader) { num2++; if (acceptedDomain.Default) { text = acceptedDomain.DomainName.Domain; } if (acceptedDomain.DomainType == AcceptedDomainType.Authoritative) { if (++num > 200) { shouldAdd = false; } hashSet.Add(acceptedDomain.DomainName.Domain); } else if (acceptedDomain.DomainType == AcceptedDomainType.InternalRelay) { if (++num > 200) { shouldAdd = false; } hashSet2.Add(acceptedDomain.DomainName.Domain); } } if (num2 == 0) { TraceWrapper.SearchLibraryTracer.TraceError(0, "No AcceptedDomain objects returned", new object[0]); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "msExchAcceptedDomain object not found in Organization {0}", new object[] { orgContainer }); } if (string.IsNullOrEmpty(text)) { TraceWrapper.SearchLibraryTracer.TraceError(0, "Null/Empty AcceptedDomainFqdn returned", new object[0]); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "DefaultDomain not found in Organization {0}", new object[] { orgContainer }); } return(new OrganizationConfigCache.Item(text, readTrackingEnabled, hashSet, hashSet2)); }
private static RecipientTrackingEvent Create(string domain, string recipientEmail, string recipientDisplayName, string deliveryStatusString, string eventDescriptionString, string[] eventData, string server, DateTime date, string internalIdString, string uniquePathId, bool hiddenRecipient, bool?bccRecipient, string rootAddress, Microsoft.Exchange.SoapWebClient.EWS.TrackingPropertyType[] properties) { if (string.IsNullOrEmpty(recipientEmail)) { TraceWrapper.SearchLibraryTracer.TraceError <string>(0, "Null recipient address in WS-RecipientTrackingEvent: {0}", recipientEmail); TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "Null recipient in WS-response", new object[0]); } SmtpAddress smtpAddress = new SmtpAddress(recipientEmail); if (!smtpAddress.IsValidAddress) { TraceWrapper.SearchLibraryTracer.TraceError <SmtpAddress>(0, "Corrupt recipient address in RD-RecipientTrackingEvent: {0}", smtpAddress); TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "Invalid recipient address {0} in WS-response", new object[] { smtpAddress }); } recipientDisplayName = (recipientDisplayName ?? smtpAddress.ToString()); DeliveryStatus deliveryStatus; if (!EnumValidator <DeliveryStatus> .TryParse(deliveryStatusString, EnumParseOptions.Default, out deliveryStatus)) { TraceWrapper.SearchLibraryTracer.TraceDebug <string>(0, "Skipping event because of unknown delivery-status value in WS-RecipientTrackingEvent: {0}", deliveryStatusString); return(null); } EventDescription eventDescription; if (!EnumValidator <EventDescription> .TryParse(eventDescriptionString, EnumParseOptions.Default, out eventDescription)) { TraceWrapper.SearchLibraryTracer.TraceDebug <string>(0, "Skipping event because of unknown event-description in WS-RecipientTrackingEvent: {0}", eventDescriptionString); return(null); } if (string.IsNullOrEmpty(internalIdString)) { TraceWrapper.SearchLibraryTracer.TraceError <string>(0, "Null or empty internalIdString in RD-RecipientTrackingEvent: {0}", internalIdString); TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "No InternalId {0} in WS-response", new object[0]); } long num = 0L; if (!long.TryParse(internalIdString, out num) || num < 0L) { TraceWrapper.SearchLibraryTracer.TraceError <string>(0, "Non-numeric or negative internalIdString in RD-RecipientTrackingEvent: {0}", internalIdString); TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "Invalid InternalId {0} in WS-response", new object[] { internalIdString }); } TrackingExtendedProperties trackingExtendedProperties = TrackingExtendedProperties.CreateFromTrackingPropertyArray(properties); if (eventDescription == EventDescription.PendingModeration && !string.IsNullOrEmpty(trackingExtendedProperties.ArbitrationMailboxAddress) && !SmtpAddress.IsValidSmtpAddress(trackingExtendedProperties.ArbitrationMailboxAddress)) { TraceWrapper.SearchLibraryTracer.TraceDebug <string>(0, "Arbitration address is in the extended proprties but it's invalid: {0}", trackingExtendedProperties.ArbitrationMailboxAddress); TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "Invalid ArbitrationMailboxAddress property {0} in WS-response", new object[] { trackingExtendedProperties.ArbitrationMailboxAddress }); } return(new RecipientTrackingEvent(domain, smtpAddress, recipientDisplayName, deliveryStatus, EventType.Pending, eventDescription, eventData, server, date, num, uniquePathId, hiddenRecipient, bccRecipient, rootAddress, true, trackingExtendedProperties)); }
public override LocalQuery CreateLocalQuery(ClientContext clientContext, DateTime requestCompletionDeadline) { TraceWrapper.SearchLibraryTracer.TraceError(this.GetHashCode(), "Attempted to create local query in x-forest case.", new object[0]); TrackingError trackingError = new TrackingError(ErrorCode.UnexpectedErrorPermanent, string.Empty, "Local autodiscover query for Cross-Forest disallowed", string.Empty); TrackingFatalException ex = new TrackingFatalException(trackingError, null, false); DiagnosticWatson.SendWatsonWithoutCrash(ex, "CreateLocalQuery", TimeSpan.FromDays(1.0)); throw ex; }
public override BaseQuery CreateFromGroup(RecipientData recipientData, BaseQuery[] groupMembers, bool groupCapped) { TraceWrapper.SearchLibraryTracer.TraceError(this.GetHashCode(), "Attempted to create group query in x-forest case.", new object[0]); TrackingError trackingError = new TrackingError(ErrorCode.UnexpectedErrorPermanent, string.Empty, "Group autodiscover query for Cross-Forest disallowed", string.Empty); TrackingFatalException ex = new TrackingFatalException(trackingError, null, false); DiagnosticWatson.SendWatsonWithoutCrash(ex, "CreateFromGroup", TimeSpan.FromDays(1.0)); throw ex; }
public string GetDefaultDomain(OrganizationId organizationId) { OrganizationConfigCache.Item item = this.organizationConfigCache.Get(organizationId); if (item == null || string.IsNullOrEmpty(item.DefaultDomain)) { TraceWrapper.SearchLibraryTracer.TraceError(this.GetHashCode(), "Cannot get domain from org-id cache", new object[0]); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "No default domain found for Organization {0}", new object[] { organizationId }); } return(item.DefaultDomain); }
private OrganizationRelationship TryGetOrganizationRelationship(OrganizationId orgId, string targetDomain) { OrganizationIdCacheValue organizationIdCacheValue = OrganizationIdCache.Singleton.Get(orgId); if (organizationIdCacheValue == null) { TraceWrapper.SearchLibraryTracer.TraceError(this.GetHashCode(), "Null cache value returned from OrganizationIdCacheValue", new object[0]); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "Organization Relationships could not be read for organization {0}", new object[] { orgId }); } return(organizationIdCacheValue.GetOrganizationRelationship(targetDomain)); }
public static RemoteSiteInCurrentOrgTrackingAuthority Create(ADObjectId siteADObjectId, DirectoryContext directoryContext, int minServerVersionRequested, bool useServersCache) { string text = ServerCache.Instance.GetDefaultDomain(directoryContext.OrganizationId); int version = 0; Uri uri = null; if (useServersCache) { TraceWrapper.SearchLibraryTracer.TraceDebug <ADObjectId>(0, "Creating remote tracking authority via ServersCache for site: {0}", siteADObjectId); try { MiniServer anyBackEndServerFromASite = ServersCache.GetAnyBackEndServerFromASite(siteADObjectId, minServerVersionRequested, false); version = anyBackEndServerFromASite.VersionNumber; TraceWrapper.SearchLibraryTracer.TraceDebug <string, ServerVersion>(0, "Found remote server {0} running {1}.", anyBackEndServerFromASite.Fqdn, anyBackEndServerFromASite.AdminDisplayVersion); if (anyBackEndServerFromASite.MajorVersion >= 15) { BackEndServer backEndServer = new BackEndServer(anyBackEndServerFromASite.Fqdn, version); uri = BackEndLocator.GetBackEndWebServicesUrl(backEndServer); } else { TraceWrapper.SearchLibraryTracer.TraceDebug(0, "Server found was E14, finding new tracking authority via ServiceTopology.", new object[0]); uri = ServerCache.Instance.GetCasServerUri(siteADObjectId, minServerVersionRequested, out version); } goto IL_118; } catch (BackEndLocatorException ex) { TraceWrapper.SearchLibraryTracer.TraceError <string>(0, "Failed to acquire EWS URI from BackEndLocator with exception: {0}", ex.ToString()); TrackingFatalException.RaiseET(ErrorCode.CASUriDiscoveryFailure, siteADObjectId.ToString()); goto IL_118; } catch (ServerHasNotBeenFoundException ex2) { TraceWrapper.SearchLibraryTracer.TraceError <string>(0, "Failed to locate remote backend server from ServersCache with exception: {0}", ex2.ToString()); TrackingFatalException.RaiseET(ErrorCode.CASUriDiscoveryFailure, siteADObjectId.ToString()); goto IL_118; } } TraceWrapper.SearchLibraryTracer.TraceDebug(0, "Creating remote tracking authority via ServiceTopology.", new object[0]); uri = ServerCache.Instance.GetCasServerUri(siteADObjectId, minServerVersionRequested, out version); IL_118: if (null == uri) { TraceWrapper.SearchLibraryTracer.TraceError(0, "No suitable authority URI found.", new object[0]); TrackingFatalException.RaiseET(ErrorCode.CASUriDiscoveryFailure, siteADObjectId.ToString()); } return(new RemoteSiteInCurrentOrgTrackingAuthority(text, TrackingAuthorityKind.RemoteSiteInCurrentOrg, siteADObjectId, uri, version)); }
public Uri GetCasServerUri(ADObjectId site, int minServerVersionRequested, out int serverVersion) { SortedDictionary <int, List <WebServicesService> > uriVersions = null; serverVersion = 0; try { ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MessageTracking\\ServerCache.cs", "GetCasServerUri", 673); currentServiceTopology.ForEach <WebServicesService>(delegate(WebServicesService service) { if (service.ServerVersionNumber >= minServerVersionRequested && service.Site.Id.Equals(site) && service.ClientAccessType == ClientAccessType.InternalNLBBypass) { if (uriVersions == null) { uriVersions = new SortedDictionary <int, List <WebServicesService> >(); } int key2 = service.ServerVersionNumber >> 16; if (!uriVersions.ContainsKey(key2)) { uriVersions[key2] = new List <WebServicesService>(); } uriVersions[key2].Add(service); } }, "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\MessageTracking\\ServerCache.cs", "GetCasServerUri", 674); } catch (ServiceDiscoveryTransientException ex) { TraceWrapper.SearchLibraryTracer.TraceError <ServiceDiscoveryTransientException>(this.GetHashCode(), "Transient exception getting Internal CAS URI: {0}", ex); TrackingTransientException.RaiseETX(ErrorCode.CASUriDiscoveryFailure, site.ToString(), ex.ToString()); } catch (ServiceDiscoveryPermanentException ex2) { TraceWrapper.SearchLibraryTracer.TraceError <ServiceDiscoveryPermanentException>(this.GetHashCode(), "Permanent exception getting Internal CAS URI: {0}", ex2); TrackingFatalException.RaiseETX(ErrorCode.CASUriDiscoveryFailure, site.ToString(), ex2.ToString()); } if (uriVersions != null && uriVersions.Count > 0) { int key = uriVersions.Last <KeyValuePair <int, List <WebServicesService> > >().Key; List <WebServicesService> value = uriVersions.Last <KeyValuePair <int, List <WebServicesService> > >().Value; int index = ServerCache.rand.Next(value.Count); WebServicesService webServicesService = value.ElementAt(index); TraceWrapper.SearchLibraryTracer.TraceDebug <Uri, string>(this.GetHashCode(), "Using CAS URI: {0}, Version {1}", webServicesService.Url, new ServerVersion(webServicesService.ServerVersionNumber).ToString()); serverVersion = webServicesService.ServerVersionNumber; return(webServicesService.Url); } TraceWrapper.SearchLibraryTracer.TraceError <string, string>(this.GetHashCode(), "Failed to find any CAS server in site: {0}, with min version {1}", site.ToString(), new ServerVersion(minServerVersionRequested).ToString()); return(null); }
public static RemoteSiteInCurrentOrgTrackingAuthority Create(ADObjectId siteADObjectId, DirectoryContext directoryContext, ADUser user) { TraceWrapper.SearchLibraryTracer.TraceDebug(0, "Creating remote tracking authority via BackEndLocator for user.", new object[0]); string text = ServerCache.Instance.GetDefaultDomain(directoryContext.OrganizationId); BackEndServer backEndServer = BackEndLocator.GetBackEndServer(user); Uri backEndWebServicesUrl = BackEndLocator.GetBackEndWebServicesUrl(backEndServer); int version = backEndServer.Version; if (null == backEndWebServicesUrl) { TraceWrapper.SearchLibraryTracer.TraceError(0, "No suitable authority URI found.", new object[0]); TrackingFatalException.RaiseET(ErrorCode.CASUriDiscoveryFailure, siteADObjectId.ToString()); } TraceWrapper.SearchLibraryTracer.TraceDebug <Uri>(0, "Using EWS URI: {0}", backEndWebServicesUrl); return(new RemoteSiteInCurrentOrgTrackingAuthority(text, TrackingAuthorityKind.RemoteSiteInCurrentOrg, siteADObjectId, backEndWebServicesUrl, version)); }
public ServerInfo GetUserServer(ADUser trackingUser) { ADObjectId database = trackingUser.Database; if (database == null) { TraceWrapper.SearchLibraryTracer.TraceError <ADObjectId>(this.GetHashCode(), "Null DataBase ID for user: {0}", trackingUser.Id); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "Null Database attribute for user {0}", new object[] { trackingUser.Id }); } string serverNameForMailboxDatabase = this.GetServerNameForMailboxDatabase(database); return(this.FindMailboxOrHubServer(serverNameForMailboxDatabase, 34UL)); }
public static RemoteSiteInCurrentOrgTrackingAuthority Create(ServerInfo serverInfo, DirectoryContext directoryContext) { int version = serverInfo.AdminDisplayVersion.ToInt(); TraceWrapper.SearchLibraryTracer.TraceDebug <string, ServerVersion>(0, "Creating remote tracking authority via BackEndLocator for server {0} running {1}.", serverInfo.Key, serverInfo.AdminDisplayVersion); string text = ServerCache.Instance.GetDefaultDomain(directoryContext.OrganizationId); BackEndServer backEndServer = new BackEndServer(serverInfo.Key, version); Uri backEndWebServicesUrl = BackEndLocator.GetBackEndWebServicesUrl(backEndServer); if (null == backEndWebServicesUrl) { TraceWrapper.SearchLibraryTracer.TraceError(0, "No suitable authority URI found.", new object[0]); TrackingFatalException.RaiseET(ErrorCode.CASUriDiscoveryFailure, serverInfo.ServerSiteId.ToString()); } TraceWrapper.SearchLibraryTracer.TraceDebug <Uri>(0, "Using EWS URI: {0}", backEndWebServicesUrl); return(new RemoteSiteInCurrentOrgTrackingAuthority(text, TrackingAuthorityKind.RemoteSiteInCurrentOrg, serverInfo.ServerSiteId, backEndWebServicesUrl, version)); }
public TrackingAuthority FindLocationForOrgServer(ServerInfo serverInfo) { TraceWrapper.SearchLibraryTracer.TraceDebug <string>(this.GetHashCode(), "Trying to get authority for Server: {0}", serverInfo.Key); if (serverInfo.ServerSiteId == null) { TraceWrapper.SearchLibraryTracer.TraceError <string>(this.GetHashCode(), "Null siteId for Server: {0}", serverInfo.Key); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "Site attribute was missing for server {0}", new object[] { serverInfo.Key }); } if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MessageTracking.UseBackEndLocator.Enabled&& serverInfo.AdminDisplayVersion.Major >= 15) { return(this.GetAuthorityForSiteByServer(serverInfo)); } return(this.GetAuthorityForSite(serverInfo.ServerSiteId)); }
public static string GetServerFromDatabase(IConfigurationSession globalConfigSession, ADObjectId dataBaseId) { Database database = globalConfigSession.Read <Database>(dataBaseId); if (database == null) { TraceWrapper.SearchLibraryTracer.TraceError <ADObjectId>(0, "Null Database read for DataBase ID: {0}", dataBaseId); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "No object: {0}", new object[] { dataBaseId }); } ADObjectId server = database.Server; if (server == null) { TraceWrapper.SearchLibraryTracer.TraceError <ADObjectId>(0, "Null Server ID returned for DataBase ID: {0}", dataBaseId); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "No msExchOwningServer attribute for DataBase-Id {0}", new object[] { dataBaseId }); } Server server2 = globalConfigSession.Read <Server>(server); if (server2 == null) { TraceWrapper.SearchLibraryTracer.TraceError <ADObjectId>(0, "Null Server read for DataBase ID: {0}", dataBaseId); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "No server object for {0} for DataBase-Id {1}", new object[] { server, dataBaseId }); } if (string.IsNullOrEmpty(server2.Fqdn)) { TraceWrapper.SearchLibraryTracer.TraceError <ADObjectId>(0, "Null/Empty FQDN for server with ID: {0} for user", server); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "No FQDN found for server {0}", new object[] { server }); } return(server2.Fqdn); }
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 override string ToString() { SmtpAddress?smtpAddress = null; if (this.ReferralEvent.EventDescription == EventDescription.TransferredToPartnerOrg && this.ReferralEvent.EventData != null && this.ReferralEvent.EventData.Length > 0) { smtpAddress = new SmtpAddress?(new SmtpAddress(this.ReferralEvent.EventData[0])); if (!smtpAddress.Value.IsValidAddress) { TraceWrapper.SearchLibraryTracer.TraceError(this.GetHashCode(), "Federated delivery email address invalid", new object[0]); TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "RecipientEvent Invalid: Federated Delivery Address incorrect {0}", new object[] { smtpAddress.ToString() }); } } string text = null; string text2 = null; if (this.ReferralEvent.EventDescription == EventDescription.SmtpSendCrossSite) { string[] eventData = this.ReferralEvent.EventData; if (eventData == null || eventData.Length < 2) { TraceWrapper.SearchLibraryTracer.TraceError(this.GetHashCode(), "No server-data for XSite send", new object[0]); TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "RecipientEvent Invalid: No server-name for cross-site SMTP send event", new object[0]); } text = this.ReferralEvent.EventData[1]; } if (this.ReferralEvent.EventDescription == EventDescription.PendingModeration) { text2 = this.ReferralEvent.ExtendedProperties.ArbitrationMailboxAddress; } return(string.Format("Fed={0},Mid={1},Server={2},authority={3},ArbMbx={4}", new object[] { (smtpAddress == null) ? "<null>" : smtpAddress.Value.ToString(), this.MessageId, (text == null) ? "<null>" : text, this.Authority.ToString(), (text2 == null) ? "<null>" : text2 })); }
private void FixupHARedirectEvent() { string text = string.Empty; Match match = MessageTrackingLogEntry.serverNameFromHAContext.Match(this.rowData.Context); if (match.Success) { text = match.Groups[1].Value; } else { TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "Failed to get destination server value from HAREDIRECT event. MessageId: {0}. Server: {1}. Value {2}", new object[] { this.rowData.MessageId, this.Server, this.rowData.Context }); } this.clientHostName = this.rowData.ServerHostName; this.serverHostName = text; }
private static IList <string> GetDagMembers(IConfigurationSession globalConfigSession, ADObjectId databaseAvailabilityGroupId) { List <string> list = new List <string>(5); DatabaseAvailabilityGroup databaseAvailabilityGroup = globalConfigSession.Read <DatabaseAvailabilityGroup>(databaseAvailabilityGroupId); if (databaseAvailabilityGroup == null) { TraceWrapper.SearchLibraryTracer.TraceError <ADObjectId>(0, "Null DAG object read for ADObjectId: {0}", databaseAvailabilityGroupId); return(list); } if (databaseAvailabilityGroup.Servers == null) { TraceWrapper.SearchLibraryTracer.TraceError <ADObjectId>(0, "Servers attribute set to null for DAG-Id: {0}", databaseAvailabilityGroupId); return(list); } foreach (ADObjectId adobjectId in databaseAvailabilityGroup.Servers) { Server server = globalConfigSession.Read <Server>(adobjectId); if (server == null) { TraceWrapper.SearchLibraryTracer.TraceError <ADObjectId, ADObjectId>(0, "Null Server attribute was read for server-ID: {0} for DAG-Id: {1}", adobjectId, databaseAvailabilityGroupId); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "NonExistent Object: {0}", new object[] { adobjectId }); } if (string.IsNullOrEmpty(server.Fqdn)) { TraceWrapper.SearchLibraryTracer.TraceError <ADObjectId, ADObjectId>(0, "Null/Empty FQDN for server with ID: {0} for DAG-Id: {1}", adobjectId, databaseAvailabilityGroupId); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "Missing FQDN: {0}", new object[] { adobjectId }); } TraceWrapper.SearchLibraryTracer.TraceDebug <string>(0, "Found server: {0}", server.Fqdn); list.Add(server.Fqdn); } return(list); }
public List <ServerInfo> GetDagServers(ServerInfo server) { List <ServerInfo> list = new List <ServerInfo>(8); ADObjectId databaseAvailabilityGroup = server.DatabaseAvailabilityGroup; bool flag = false; if (databaseAvailabilityGroup != null) { IList <string> list2 = this.databaseAvailabilityGroupCache.Get(databaseAvailabilityGroup); foreach (string text in list2) { if (string.Equals(text, server.Key, StringComparison.OrdinalIgnoreCase)) { flag = true; } ServerInfo item = this.transportServerConfigCache.Get(text); list.Add(item); } } if (!flag) { if (databaseAvailabilityGroup == null) { TraceWrapper.SearchLibraryTracer.TraceDebug <string>(this.GetHashCode(), "Server {0} does not have a DAG specified", server.Key); list.Add(server); } else { TraceWrapper.SearchLibraryTracer.TraceError <string, ADObjectId>(this.GetHashCode(), "Server {0} was not present in DAG {1}", server.Key, databaseAvailabilityGroup); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "Server {0} not in DatabaseAvailabilityGroup {1}", new object[] { server.Key, databaseAvailabilityGroup }); } } return(list); }
private void FixupFederatedDeliveryEvents() { string text = null; List <MessageTrackingLogEntry> list = null; foreach (MessageTrackingLogEntry messageTrackingLogEntry in this.entriesForMailItem) { if (messageTrackingLogEntry.SourceContext.Equals("Federated Delivery Encryption Agent", StringComparison.OrdinalIgnoreCase) && messageTrackingLogEntry.EventId == MessageTrackingEvent.EXPAND) { if (messageTrackingLogEntry.RecipientAddresses != null && messageTrackingLogEntry.RecipientAddresses.Length != 0) { if (messageTrackingLogEntry.RecipientAddresses.Length != 1) { TraceWrapper.SearchLibraryTracer.TraceError <int>(this.GetHashCode(), "Federated delivery EXPAND event expected to have only 0 or 1 recipients. Found: {0}", messageTrackingLogEntry.RecipientAddresses.Length); TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "Federated Delivery Expand event had multiple recipients", new object[0]); } text = messageTrackingLogEntry.RecipientAddresses[0]; } messageTrackingLogEntry.RecipientAddresses = new string[] { messageTrackingLogEntry.RelatedRecipientAddress }; if (list == null) { list = new List <MessageTrackingLogEntry>(this.entriesForMailItem.Count); } list.Add(messageTrackingLogEntry); } } if (!string.IsNullOrEmpty(text)) { foreach (MessageTrackingLogEntry messageTrackingLogEntry2 in list) { messageTrackingLogEntry2.FederatedDeliveryAddress = text; } } }
private static ServerInfo IdentifyArbitrationMailboxServer(SmtpAddress arbMailboxAddress, DirectoryContext directoryContext) { PropertyDefinition[] properties = new PropertyDefinition[] { IADMailStorageSchema.ServerName }; ADRawEntry adrawEntry = null; try { adrawEntry = directoryContext.TenantGalSession.FindByProxyAddress(new SmtpProxyAddress((string)arbMailboxAddress, true), properties); } catch (NonUniqueRecipientException ex) { TraceWrapper.SearchLibraryTracer.TraceError <string>(0, "Caught NonUniqueRecipientException when attempting to look up server for arbitration mailbox {0}", (string)arbMailboxAddress); TrackingFatalException.RaiseEDX(ErrorCode.InvalidADData, ex.ToString(), "Multiple users had proxy address {0}", new object[] { arbMailboxAddress }); } if (adrawEntry == null) { TraceWrapper.SearchLibraryTracer.TraceError <string>(0, "Attempt to get server for arbitration mailbox '{0}' failed.", (string)arbMailboxAddress); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "Arbitration Mailbox not found for email-address {0}", new object[] { arbMailboxAddress }); } string text = (string)adrawEntry[IADMailStorageSchema.ServerName]; if (!string.IsNullOrEmpty(text)) { return(ServerCache.Instance.FindMailboxOrHubServer(text, 2UL)); } return(ServerInfo.NotFound); }
private TrackingAuthority GetAuthorityForServerInDomain(string serverName, out bool serverNotFound) { ServerInfo serverInfo = ServerInfo.NotFound; serverNotFound = false; if (!string.IsNullOrEmpty(serverName)) { serverInfo = ServerCache.Instance.FindMailboxOrHubServer(serverName, 34UL); } if (serverInfo.Status == ServerStatus.NotFound) { TraceWrapper.SearchLibraryTracer.TraceError <string>(this.GetHashCode(), "Could not find server: {0}", serverName); serverNotFound = true; TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "Server {0} not found", new object[] { serverName }); } if (serverInfo.Status == ServerStatus.Searchable) { return(this.FindLocationForOrgServer(serverInfo)); } return(null); }
public T GetCustomData <T>(string key, T defaultValue) { KeyValuePair <string, object>[] customData = this.CustomData; if (customData == null || customData.Length == 0) { return(defaultValue); } foreach (KeyValuePair <string, object> keyValuePair in customData) { if (string.Equals(keyValuePair.Key, key, StringComparison.OrdinalIgnoreCase)) { object value = keyValuePair.Value; if (!(value is T)) { TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "The message-tracking data on server {0} had invalid data in the CustomData column for this message", new object[] { this.ServerFqdn }); } return((T)((object)value)); } } return(defaultValue); }
internal static MessageTrackingSearchResult Create(FindMessageTrackingSearchResultType wsResult, string targetInfoForDisplay) { if (wsResult.Sender == null) { TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "WS-Response Validation Error: Sender is null in FindMessageTrackingReport response from {0}", new object[] { targetInfoForDisplay }); } SmtpAddress smtpAddress = new SmtpAddress(wsResult.Sender.EmailAddress); if (!smtpAddress.IsValidAddress || string.IsNullOrEmpty(wsResult.Sender.Name)) { TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "WS-Response Validation Error: Sender {0} is invalid in FindMessageTrackingReport response from {1}", new object[] { smtpAddress.ToString(), targetInfoForDisplay }); } smtpAddress = SmtpAddress.Parse(wsResult.Sender.EmailAddress); string name = wsResult.Sender.Name; EmailAddressType[] recipients = wsResult.Recipients; SmtpAddress[] array = new SmtpAddress[recipients.Length]; if (recipients == null || recipients.Length == 0) { TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "WS-Response Validation Error: No recipients in FindMessageTrackingReport response from {0}", new object[] { targetInfoForDisplay }); } for (int i = 0; i < recipients.Length; i++) { if (recipients[i] == null) { TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "WS-Response Validation Error: Null recipient in FindMessageTrackingReport response from {0}", new object[] { targetInfoForDisplay }); } array[i] = new SmtpAddress(recipients[i].EmailAddress); if (!array[i].IsValidAddress) { TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "WS-Response Validation Error: Invalid Recipient {0} in FindMessageTrackingReport response from {1}", new object[] { array[i].ToString(), targetInfoForDisplay }); } } MessageTrackingReportId identity = null; if (!MessageTrackingReportId.TryParse(wsResult.MessageTrackingReportId, out identity)) { TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "WS-Response Validation Error: Invalid report ID {0} in FindMessageTrackingReport response from {1}", new object[] { wsResult.MessageTrackingReportId, targetInfoForDisplay }); } return(new MessageTrackingSearchResult(identity, smtpAddress, name, array, wsResult.Subject, wsResult.SubmittedTime, wsResult.PreviousHopServer, wsResult.FirstHopServer)); }
private MessageTrackingLogEntry(MessageTrackingLogRow rowData) { this.rowData = rowData; string text = Names <MessageTrackingEvent> .Map[(int)this.rowData.EventId]; if (this.rowData.EventId == MessageTrackingEvent.TRANSFER || (this.rowData.EventId == MessageTrackingEvent.RESUBMIT && this.rowData.Source == MessageTrackingSource.REDUNDANCY)) { long num = 0L; if (this.rowData.References == null || this.rowData.References.Length != 1 || !long.TryParse(this.rowData.References[0], out num)) { TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "RelatedInternalId could not be parsed for TRANSFER event from server {0}", new object[] { this.Server }); } this.relatedMailItemId = num; return; } if (this.rowData.EventId == MessageTrackingEvent.RECEIVE) { if (this.rowData.Source == MessageTrackingSource.SMTP && string.IsNullOrEmpty(this.rowData.ClientHostName) && string.IsNullOrEmpty(this.rowData.ClientIP)) { TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "No ClientHostName or ClientIP for SMTP RECEIVE from server {0}", new object[] { this.Server }); return; } } else { if (this.rowData.EventId == MessageTrackingEvent.SEND && this.rowData.Source == MessageTrackingSource.SMTP) { if (string.IsNullOrEmpty(this.rowData.ServerHostName) && string.IsNullOrEmpty(this.rowData.ServerIP)) { TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "No ServerHostName or ServerIP for SMTP SEND from server {0}", new object[] { this.Server }); } this.ProcessOutboundProxyTargetServer(); return; } if (this.rowData.EventId == MessageTrackingEvent.DELIVER && this.rowData.Source == MessageTrackingSource.STOREDRIVER && this.rowData.RecipientStatuses != null) { if (this.rowData.RecipientAddresses == null || this.rowData.RecipientAddresses.Length != this.rowData.RecipientStatuses.Length) { TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "Mismatched RecipientAddress and RecipientStatus counts for STOREDRIVER DELIVER from server {0}", new object[] { this.Server }); } for (int i = 0; i < this.rowData.RecipientAddresses.Length; i++) { if (!string.IsNullOrEmpty(this.rowData.RecipientStatuses[i])) { if (this.recipientFolders == null) { this.recipientFolders = new Dictionary <string, string>(this.rowData.RecipientAddresses.Length); } this.recipientFolders.Add(this.rowData.RecipientAddresses[i], this.rowData.RecipientStatuses[i]); } } return; } if (this.rowData.EventId == MessageTrackingEvent.INITMESSAGECREATED) { if (this.rowData.References == null || this.rowData.References.Length < 1 || string.IsNullOrEmpty(this.rowData.References[0]) || !SmtpAddress.IsValidSmtpAddress(this.rowData.Context)) { TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "No RelatedMessageId for INITMESSAGECREATED from server {0}", new object[] { this.Server }); } this.arbitrationMailboxAddress = SmtpAddress.Parse(this.rowData.Context); return; } if (this.rowData.EventId == MessageTrackingEvent.MODERATORAPPROVE || this.rowData.EventId == MessageTrackingEvent.MODERATORREJECT || this.rowData.EventId == MessageTrackingEvent.MODERATIONEXPIRE) { if (this.rowData.References == null || this.rowData.References.Length < 1 || string.IsNullOrEmpty(this.rowData.References[0])) { TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "No RelatedMessageId for {0}", new object[] { text, this.Server }); return; } } else if (this.rowData.EventId == MessageTrackingEvent.HAREDIRECT && this.rowData.Source == MessageTrackingSource.SMTP) { this.FixupHARedirectEvent(); } } }