internal static string OrganizationNameForLogging(IRoutingKey key) { RoutingItemType routingItemType = key.RoutingItemType; if (routingItemType != RoutingItemType.ArchiveSmtp) { switch (routingItemType) { case RoutingItemType.MailboxGuid: { MailboxGuidRoutingKey mailboxGuidRoutingKey = key as MailboxGuidRoutingKey; return(mailboxGuidRoutingKey.TenantDomain); } case RoutingItemType.Smtp: { SmtpRoutingKey smtpRoutingKey = key as SmtpRoutingKey; return(smtpRoutingKey.SmtpAddress.Domain); } case RoutingItemType.LiveIdMemberName: { LiveIdMemberNameRoutingKey liveIdMemberNameRoutingKey = key as LiveIdMemberNameRoutingKey; return(liveIdMemberNameRoutingKey.OrganizationDomain); } } return(string.Empty); } ArchiveSmtpRoutingKey archiveSmtpRoutingKey = key as ArchiveSmtpRoutingKey; return(archiveSmtpRoutingKey.SmtpAddress.Domain); }
string ISharedCache.GetSharedCacheKeyFromRoutingKey(IRoutingKey key) { string text = string.Empty; switch (key.RoutingItemType) { case RoutingItemType.ArchiveSmtp: { ArchiveSmtpRoutingKey archiveSmtpRoutingKey = key as ArchiveSmtpRoutingKey; text = SharedCacheClientWrapper.MakeCacheKey(SharedCacheClientWrapper.AnchorSource.Smtp, archiveSmtpRoutingKey.SmtpAddress); text += "_Archive"; break; } case RoutingItemType.DatabaseGuid: { DatabaseGuidRoutingKey databaseGuidRoutingKey = key as DatabaseGuidRoutingKey; text = SharedCacheClientWrapper.MakeCacheKey(SharedCacheClientWrapper.AnchorSource.DatabaseGuid, databaseGuidRoutingKey.DatabaseGuid); break; } case RoutingItemType.MailboxGuid: { MailboxGuidRoutingKey mailboxGuidRoutingKey = key as MailboxGuidRoutingKey; text = SharedCacheClientWrapper.MakeCacheKey(SharedCacheClientWrapper.AnchorSource.MailboxGuid, mailboxGuidRoutingKey.MailboxGuid); break; } case RoutingItemType.Smtp: { SmtpRoutingKey smtpRoutingKey = key as SmtpRoutingKey; text = SharedCacheClientWrapper.MakeCacheKey(SharedCacheClientWrapper.AnchorSource.Smtp, smtpRoutingKey.SmtpAddress); break; } case RoutingItemType.ExternalDirectoryObjectId: { ExternalDirectoryObjectIdRoutingKey externalDirectoryObjectIdRoutingKey = key as ExternalDirectoryObjectIdRoutingKey; text = SharedCacheClientWrapper.MakeCacheKey(SharedCacheClientWrapper.AnchorSource.ExternalDirectoryObjectId, externalDirectoryObjectIdRoutingKey.UserGuid); break; } case RoutingItemType.LiveIdMemberName: { LiveIdMemberNameRoutingKey liveIdMemberNameRoutingKey = key as LiveIdMemberNameRoutingKey; text = SharedCacheClientWrapper.MakeCacheKey(SharedCacheClientWrapper.AnchorSource.LiveIdMemberName, liveIdMemberNameRoutingKey.LiveIdMemberName); break; } } return(text); }
private static IRoutingKey[] FindByAnchorMailbox(string anchorMailbox, IAddressFinderDiagnostics diagnostics) { if (string.IsNullOrEmpty(anchorMailbox)) { return(AddressFinderHelper.EmptyRoutingKeyArray); } Match match = Constants.GuidAtDomainRegex.Match(anchorMailbox); if (match != null && match.Success) { string text = match.Result("${mailboxguid}"); if (!string.IsNullOrEmpty(text)) { Guid mailboxGuid = new Guid(text); string text2 = match.Result("${domain}"); IRoutingKey routingKey = new MailboxGuidRoutingKey(mailboxGuid, text2); diagnostics.AddRoutingkey(routingKey, "MailboxGuidInAnchorMailbox"); if (string.IsNullOrEmpty(text2)) { return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[] { routingKey })); } if (SmtpAddress.IsValidSmtpAddress(anchorMailbox)) { IRoutingKey routingKey2 = new SmtpRoutingKey(new SmtpAddress(anchorMailbox)); diagnostics.AddRoutingkey(routingKey2, "FallbackSmtpAddressInAnchorMailbox"); return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[] { routingKey, routingKey2 })); } ExTraceGlobals.VerboseTracer.TraceDebug <string>(0L, "[RoutingHintAddressFinder::FindByAnchorMailbox]: Malformed smtp address in X-AnchorMailbox {0}.", anchorMailbox); } } if (SmtpAddress.IsValidSmtpAddress(anchorMailbox)) { IRoutingKey routingKey3 = new SmtpRoutingKey(new SmtpAddress(anchorMailbox)); diagnostics.AddRoutingkey(routingKey3, "SmtpAddressInAnchorMailbox"); return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[] { routingKey3 })); } ExTraceGlobals.VerboseTracer.TraceDebug <string>(0L, "[RoutingHintAddressFinder::FindByAnchorMailbox]: Invalid smtp address in X-AnchorMailbox {0}.", anchorMailbox); return(AddressFinderHelper.EmptyRoutingKeyArray); }
IRoutingKey[] IAddressFinder.Find(AddressFinderSource source, IAddressFinderDiagnostics diagnostics) { AddressFinderHelper.ThrowIfNull(source, diagnostics); string text = source.QueryString["email"]; if (!string.IsNullOrEmpty(text) && SmtpAddress.IsValidSmtpAddress(text)) { IRoutingKey routingKey = new SmtpRoutingKey(new SmtpAddress(text)); diagnostics.AddRoutingkey(routingKey, "ExplicitLogon-SMTP"); return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[] { routingKey })); } return(AddressFinderHelper.EmptyRoutingKeyArray); }
private static IRoutingKey FindBySmtpAddress(string smtpAddress, IAddressFinderDiagnostics diagnostics) { if (string.IsNullOrEmpty(smtpAddress)) { return(null); } if (!SmtpAddress.IsValidSmtpAddress(smtpAddress)) { ExTraceGlobals.VerboseTracer.TraceDebug <string>(0L, "[MapiAddressFinder::FindBySmtpAddress]: Malformed smtpAddress {0}.", smtpAddress); return(null); } IRoutingKey routingKey = new SmtpRoutingKey(new SmtpAddress(smtpAddress)); diagnostics.AddRoutingkey(routingKey, "SmtpAddressInQueryString"); return(routingKey); }
IRoutingKey[] IAddressFinder.Find(AddressFinderSource source, IAddressFinderDiagnostics diagnostics) { AddressFinderHelper.ThrowIfNull(source, diagnostics); bool selectedNodeIsLast; string explicitLogonNode = ProtocolHelper.GetExplicitLogonNode(source.ApplicationPath, source.FilePath, ExplicitLogonNode.Second, out selectedNodeIsLast); string address; if (ProtocolHelper.TryGetValidNormalizedExplicitLogonAddress(explicitLogonNode, selectedNodeIsLast, out address)) { IRoutingKey routingKey = new SmtpRoutingKey(new SmtpAddress(address)); diagnostics.AddRoutingkey(routingKey, "ExplicitLogon-SMTP"); return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[] { routingKey })); } return(AddressFinderHelper.EmptyRoutingKeyArray); }
IRoutingKey[] IAddressFinder.Find(AddressFinderSource source, IAddressFinderDiagnostics diagnostics) { AddressFinderHelper.ThrowIfNull(source, diagnostics); if (!string.IsNullOrWhiteSpace(source.Url.PathAndQuery)) { Match match = Constants.UsersEntityRegex.Match(source.Url.PathAndQuery); if (match.Success) { string address = match.Result("${address}"); if (SmtpAddress.IsValidSmtpAddress(address)) { IRoutingKey routingKey = new SmtpRoutingKey(new SmtpAddress(address)); diagnostics.AddRoutingkey(routingKey, "TargetMailbox-SMTP"); return(AddressFinderHelper.GetRoutingKeyArray(new IRoutingKey[] { routingKey })); } } } return(AddressFinderHelper.EmptyRoutingKeyArray); }
private static IRoutingKey DeserializeRoutingKey(string type, string value) { switch (type) { case "ArchiveSmtp": { ArchiveSmtpRoutingKey result; if (ArchiveSmtpRoutingKey.TryParse(value, out result)) { return(result); } break; } case "DatabaseGuid": { DatabaseGuidRoutingKey result2; if (DatabaseGuidRoutingKey.TryParse(value, out result2)) { return(result2); } break; } case "MailboxGuid": { MailboxGuidRoutingKey result3; if (MailboxGuidRoutingKey.TryParse(value, out result3)) { return(result3); } break; } case "Smtp": { SmtpRoutingKey result4; if (SmtpRoutingKey.TryParse(value, out result4)) { return(result4); } break; } case "Server": { ServerRoutingKey result5; if (ServerRoutingKey.TryParse(value, out result5)) { return(result5); } break; } case "Oid": { ExternalDirectoryObjectIdRoutingKey result6; if (ExternalDirectoryObjectIdRoutingKey.TryParse(value, out result6)) { return(result6); } break; } case "LiveIdMemberName": { LiveIdMemberNameRoutingKey result7; if (LiveIdMemberNameRoutingKey.TryParse(value, out result7)) { return(result7); } break; } } return(new UnknownRoutingKey(type, value)); }