private bool TryGetPersonalizedServer(string userLegacyDN, out string personalizedServer) { personalizedServer = string.Empty; bool flag = true; NspiPrincipal nspiPrincipal; if (string.IsNullOrEmpty(userLegacyDN) || LegacyDN.StringComparer.Equals(userLegacyDN, this.LegacyDistinguishedName)) { this.protocolLogSession[ProtocolLog.Field.OperationSpecific] = "Self"; nspiPrincipal = this.nspiPrincipal; } else { this.protocolLogSession[ProtocolLog.Field.OperationSpecific] = "Other"; nspiPrincipal = this.NspiPrincipalFromLegacyDN(userLegacyDN); flag = false; if (nspiPrincipal == null) { return(false); } } if (!flag && nspiPrincipal.ExchangeVersion != null && nspiPrincipal.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2012)) { string clientAccessServerLegacyDN = this.GetClientAccessServerLegacyDN(userLegacyDN); RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "RfriContext.GetClientAccessServerLegacyDN: {0}", RfriContext.GetString(clientAccessServerLegacyDN)); ServerFqdnCache.LookupFQDNByLegacyDN(clientAccessServerLegacyDN, out personalizedServer); RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "ServerFqdnCache.LookupFQDNByLegacyDN: {0}", RfriContext.GetString(personalizedServer)); return(true); } SmtpAddress primarySmtpAddress = nspiPrincipal.PrimarySmtpAddress; if (nspiPrincipal.ExchangeGuid != Guid.Empty) { personalizedServer = ExchangeRpcClientAccess.CreatePersonalizedServer(nspiPrincipal.ExchangeGuid, nspiPrincipal.PrimarySmtpAddress.Domain); RfriContext.ReferralTracer.TraceDebug <string>((long)this.ContextHandle, "RfriContext.GetPersonalizedServer: {0}", RfriContext.GetString(personalizedServer)); return(true); } return(false); }
// Token: 0x0600070D RID: 1805 RVA: 0x000296EC File Offset: 0x000278EC protected override AnchorMailbox ResolveAnchorMailbox() { UriBuilder uriBuilder = new UriBuilder(base.ClientRequest.Url); if (string.IsNullOrEmpty(base.ClientRequest.Url.Query)) { throw new HttpProxyException(HttpStatusCode.NotFound, 3001, "No proxy destination is specified!"); } RpcHttpQueryString rpcHttpQueryString = new RpcHttpQueryString(uriBuilder.Query); this.rpcServerTarget = rpcHttpQueryString.RcaServer; if (SmtpAddress.IsValidSmtpAddress(this.rpcServerTarget)) { string text; HttpContextItemParser.TryGetLiveIdMemberName(base.HttpContext.Items, ref text); Guid guid; string domain; string text2; if (RequestQueryStringParser.TryGetMailboxGuid(this.rpcServerTarget, text, ref guid, ref domain, ref text2)) { MailboxGuidAnchorMailbox result; if (!string.IsNullOrEmpty(text2)) { this.rpcServerTarget = ExchangeRpcClientAccess.CreatePersonalizedServer(guid, text2); base.Logger.AppendString(3, "MailboxGuidWithDomain-ChangedToUserDomain"); result = new MailboxGuidAnchorMailbox(guid, text2, this); } else { base.Logger.AppendString(3, "MailboxGuidWithDomain"); result = new MailboxGuidAnchorMailbox(guid, domain, this); } this.updateRpcServer = true; return(result); } return(this.ResolveToDefaultAnchorMailbox(this.rpcServerTarget, "InvalidFormat")); } else { ProxyDestination proxyDestination; if (RpcHttpProxyRules.Instance.TryGetProxyDestination(this.rpcServerTarget, out proxyDestination)) { string text3 = proxyDestination.GetHostName(this.GetKeyForCasAffinity()); if (proxyDestination.IsDynamicTarget) { try { text3 = DownLevelServerManager.Instance.GetDownLevelClientAccessServerWithPreferredServer <RpcHttpService>(new ServerInfoAnchorMailbox(text3, this), text3, 1, base.Logger, proxyDestination.Version).Fqdn; } catch (NoAvailableDownLevelBackEndException) { throw new HttpProxyException(HttpStatusCode.NotFound, 3001, string.Format("Cannot find a healthy E12 or E14 CAS to proxy to: {0}", this.rpcServerTarget)); } } uriBuilder.Host = text3; uriBuilder.Port = proxyDestination.Port; uriBuilder.Scheme = Uri.UriSchemeHttps; base.Logger.Set(3, "RpcHttpProxyRules"); this.updateRpcServer = false; return(new UrlAnchorMailbox(uriBuilder.Uri, this)); } return(this.ResolveToDefaultAnchorMailbox(this.rpcServerTarget, "UnknownServerName")); } }
// Token: 0x06000773 RID: 1907 RVA: 0x0001CFD4 File Offset: 0x0001B1D4 internal static AutodiscoverCommonUserSettings GetSettingsFromRecipient(ADUser user, string emailAddress) { bool flag = AutodiscoverCommonUserSettings.IsArchiveMailUser(user) || AutodiscoverCommonUserSettings.IsEmailAddressTargetingArchive(user, emailAddress); string domain = user.PrimarySmtpAddress.Domain; Guid mailboxGuid = flag ? user.ArchiveGuid : user.ExchangeGuid; return(new AutodiscoverCommonUserSettings(flag ? AutodiscoverCommonUserSettings.GetArchiveDisplayName(user) : user.DisplayName, flag ? user.GetAlternateMailboxLegDN(user.ArchiveGuid) : user.LegacyExchangeDN, user.PrimarySmtpAddress, ExchangeRpcClientAccess.CreatePersonalizedServer(mailboxGuid, domain), mailboxGuid)); }
protected override AnchorMailbox ResolveAnchorMailbox() { UriBuilder uriBuilder = new UriBuilder(base.ClientRequest.Url); if (string.IsNullOrEmpty(base.ClientRequest.Url.Query)) { throw new HttpProxyException(HttpStatusCode.NotFound, HttpProxySubErrorCode.EndpointNotFound, "No proxy destination is specified!"); } RpcHttpQueryString rpcHttpQueryString = new RpcHttpQueryString(uriBuilder.Query); this.rpcServerTarget = rpcHttpQueryString.RcaServer; if (SmtpAddress.IsValidSmtpAddress(this.rpcServerTarget)) { Guid mailboxGuid = Guid.Empty; string text = string.Empty; try { SmtpAddress smtpAddress = new SmtpAddress(this.rpcServerTarget); mailboxGuid = new Guid(smtpAddress.Local); text = smtpAddress.Domain; } catch (FormatException) { return(this.ResolveToDefaultAnchorMailbox(this.rpcServerTarget, "InvalidFormat")); } base.Logger.Set(HttpProxyMetadata.RoutingHint, "MailboxGuidWithDomain"); if (!text.Contains(".")) { string text2 = base.HttpContext.Items[Constants.WLIDMemberName] as string; if (!string.IsNullOrEmpty(text2)) { SmtpAddress smtpAddress2 = new SmtpAddress(text2); string domain = smtpAddress2.Domain; if (domain != null && !string.Equals(domain, text, StringComparison.OrdinalIgnoreCase)) { ExTraceGlobals.BriefTracer.TraceError((long)this.GetHashCode(), "[RpcHttpProxyRequestHandler::ResolveAnchorMailbox]: Fixing up invalid domain name from client: {0} to {1}; Context {2}; State {3}", new object[] { text, domain, base.TraceContext, base.State }); text = domain; this.rpcServerTarget = ExchangeRpcClientAccess.CreatePersonalizedServer(mailboxGuid, text); base.Logger.AppendString(HttpProxyMetadata.RoutingHint, "-ChangedToUserDomain"); } } } this.updateRpcServer = true; return(new MailboxGuidAnchorMailbox(mailboxGuid, text, this)); } ProxyDestination proxyDestination; if (this.proxyRules.TryGetProxyDestination(this.rpcServerTarget, out proxyDestination)) { string text3 = proxyDestination.GetHostName(this.GetKeyForCasAffinity()); if (proxyDestination.IsDynamicTarget) { try { text3 = DownLevelServerManager.Instance.GetDownLevelClientAccessServerWithPreferredServer <RpcHttpService>(new ServerInfoAnchorMailbox(text3, this), text3, ClientAccessType.External, base.Logger, proxyDestination.Version).Fqdn; } catch (NoAvailableDownLevelBackEndException) { throw new HttpProxyException(HttpStatusCode.NotFound, HttpProxySubErrorCode.EndpointNotFound, string.Format("Cannot find a healthy E12 or E14 CAS to proxy to: {0}", this.rpcServerTarget)); } } uriBuilder.Host = text3; uriBuilder.Port = proxyDestination.Port; uriBuilder.Scheme = Uri.UriSchemeHttps; base.Logger.Set(HttpProxyMetadata.RoutingHint, "RpcHttpProxyRules"); this.updateRpcServer = false; return(new UrlAnchorMailbox(uriBuilder.Uri, this)); } return(this.ResolveToDefaultAnchorMailbox(this.rpcServerTarget, "UnknownServerName")); }