internal static IRecipientSession GetRecipientSessionFromDomain(LatencyTracker latencyTracker, string domain, bool ignoreCannotResolveTenantNameException = false) { if (latencyTracker == null) { throw new ArgumentNullException("latencyTracker"); } if (string.IsNullOrEmpty(domain)) { throw new ArgumentNullException("domain"); } ADSessionSettings sessionSettings = null; if (!Utilities.IsPartnerHostedOnly) { if (!VariantConfiguration.InvariantNoFlightingSnapshot.Global.WindowsLiveID.Enabled) { goto IL_7F; } } try { sessionSettings = DirectoryHelper.CreateADSessionSettingsFromDomain(latencyTracker, domain); goto IL_85; } catch (CannotResolveTenantNameException ex) { ExTraceGlobals.VerboseTracer.TraceWarning <string, CannotResolveTenantNameException>(0L, "[DirectoryHelper::GetRecipientSessionFromDomain] Caught CannotResolveTenantNameException when resolving tenant by domain {0}. Exception details: {1}.", domain, ex); if (!ignoreCannotResolveTenantNameException) { throw new HttpProxyException(HttpStatusCode.NotFound, HttpProxySubErrorCode.DomainNotFound, ex.Message, ex); } return(null); } IL_7F: sessionSettings = ADSessionSettings.FromRootOrgScopeSet(); IL_85: return(DirectoryHelper.CreateSession(sessionSettings)); }
internal static ITenantRecipientSession GetTenantRecipientSessionFromSmtpOrLiveId(LatencyTracker latencyTracker, string smtpOrLiveId, bool ignoreCannotResolveTenantNameException = false) { if (!Utilities.IsPartnerHostedOnly && !VariantConfiguration.InvariantNoFlightingSnapshot.Global.WindowsLiveID.Enabled) { throw new InvalidOperationException("Cannot create ITenantRecipientSession if WindowsLiveId feature is disabled."); } if (latencyTracker == null) { throw new ArgumentNullException("latencyTracker"); } if (string.IsNullOrEmpty(smtpOrLiveId)) { throw new ArgumentNullException("smtpOrLiveId"); } if (!SmtpAddress.IsValidSmtpAddress(smtpOrLiveId)) { throw new ArgumentException(string.Format("{0} is not a valid SmtpAddress.", smtpOrLiveId)); } string domain = SmtpAddress.Parse(smtpOrLiveId).Domain; ADSessionSettings sessionSettings = null; try { sessionSettings = DirectoryHelper.CreateADSessionSettingsFromDomain(latencyTracker, domain); } catch (CannotResolveTenantNameException ex) { if (!ignoreCannotResolveTenantNameException) { throw new HttpProxyException(HttpStatusCode.NotFound, HttpProxySubErrorCode.DomainNotFound, ex.Message, ex); } ExTraceGlobals.VerboseTracer.TraceWarning <string, CannotResolveTenantNameException>(0L, "[DirectoryHelper::GetTenantRecipientSessionFromSmtpOrLiveId] Caught CannotResolveTenantNameException when trying to get tenant recipient session from smtp or liveId for {0}. Exception details: {1}.", smtpOrLiveId, ex); return(null); } return(DirectorySessionFactory.Default.CreateTenantRecipientSession(null, null, CultureInfo.CurrentCulture.LCID, true, ConsistencyMode.IgnoreInvalid, null, sessionSettings, 211, "GetTenantRecipientSessionFromSmtpOrLiveId", "f:\\15.00.1497\\sources\\dev\\cafe\\src\\HttpProxy\\Misc\\DirectoryHelper.cs")); }