// Token: 0x06000031 RID: 49 RVA: 0x00003470 File Offset: 0x00001670
        internal static Uri GetRedirectUrlForTenantForest(string domain, string podRedirectTemplate, Uri originalUrl, int podSiteStartRange, int podSiteEndRange)
        {
            int    partnerId = LocalSiteCache.LocalSite.PartnerId;
            Guid   orgId;
            string redirectServer;

            if (GuidHelper.TryParseGuid(domain, out orgId))
            {
                redirectServer = EdgeSyncMservConnector.GetRedirectServer(podRedirectTemplate, orgId, partnerId, podSiteStartRange, podSiteEndRange);
            }
            else
            {
                redirectServer = EdgeSyncMservConnector.GetRedirectServer(podRedirectTemplate, string.Format("E5CB63F56E8B4b69A1F70C192276D6AD@{0}", domain), partnerId, podSiteStartRange, podSiteEndRange);
            }
            if (string.IsNullOrEmpty(redirectServer))
            {
                return(null);
            }
            UriBuilder uriBuilder = new UriBuilder(originalUrl);

            uriBuilder.Host = redirectServer;
            if (uriBuilder.Port == 444)
            {
                uriBuilder.Port = 443;
            }
            return(uriBuilder.Uri);
        }
Пример #2
0
        private void PerformLookup(string domainController, List <string> addresses)
        {
            MserveWebService mserveWebService = EdgeSyncMservConnector.CreateDefaultMserveWebService(domainController);

            if (mserveWebService == null)
            {
                throw new InvalidOperationException("Invalid MServ configuration.");
            }
            List <RecipientSyncOperation> list;

            foreach (string text in addresses)
            {
                RecipientSyncOperation recipientSyncOperation = new RecipientSyncOperation();
                if (text.StartsWith("smtp:", StringComparison.OrdinalIgnoreCase))
                {
                    recipientSyncOperation.ReadEntries.Add(text.Substring(5));
                }
                else
                {
                    recipientSyncOperation.ReadEntries.Add(text);
                }
                list = mserveWebService.Synchronize(recipientSyncOperation);
                foreach (RecipientSyncOperation recipientSyncOperation2 in list)
                {
                    base.WriteObject(new MservRecipientRecord(recipientSyncOperation2.ReadEntries[0], recipientSyncOperation2.PartnerId));
                }
            }
            list = mserveWebService.Synchronize();
            foreach (RecipientSyncOperation recipientSyncOperation3 in list)
            {
                base.WriteObject(new MservRecipientRecord(recipientSyncOperation3.ReadEntries[0], recipientSyncOperation3.PartnerId));
            }
        }
        // Token: 0x060002B8 RID: 696 RVA: 0x0000D928 File Offset: 0x0000BB28
        private string InvokeMserv(string userAddress)
        {
            int       currentSitePartnerId = HttpProxyGlobals.LocalSite.Member.PartnerId;
            string    text = null;
            long      num  = 0L;
            Exception ex   = null;

            try
            {
                text = LatencyTracker.GetLatency <string>(() => EdgeSyncMservConnector.GetRedirectServer(DatacenterRedirectStrategy.PodRedirectTemplate.Value, userAddress, currentSitePartnerId, DatacenterRedirectStrategy.PodSiteStartRange.Value, DatacenterRedirectStrategy.PodSiteEndRange.Value, false, true), out num);
            }
            catch (MServTransientException ex)
            {
            }
            catch (MServPermanentException ex)
            {
            }
            catch (InvalidOperationException ex)
            {
            }
            catch (LocalizedException ex)
            {
            }
            finally
            {
                this.RequestContext.Logger.AppendGenericInfo("MservLatency", num);
            }
            string message = string.Format("Failed to look up MSERV for address {0}.", userAddress);

            if (ex != null)
            {
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(3))
                {
                    ExTraceGlobals.VerboseTracer.TraceError <int, string, Exception>((long)this.GetHashCode(), "[DatacenterRedirectStrategy::InvokeMserv]: Context {0}. Failed to look up MSERV for address {1}. Error: {2}", this.TraceContext, userAddress, ex);
                }
                throw new HttpProxyException(HttpStatusCode.InternalServerError, 2002, message, ex);
            }
            if (string.IsNullOrEmpty(text))
            {
                if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(3))
                {
                    ExTraceGlobals.VerboseTracer.TraceError <int, string>((long)this.GetHashCode(), "[DatacenterRedirectStrategy::InvokeMserv]: Context {0}. MSERV did not return redirect server for address {1}.", this.TraceContext, userAddress);
                }
                throw new HttpProxyException(HttpStatusCode.InternalServerError, 2002, message);
            }
            return(text);
        }
Пример #4
0
        internal override bool ReadConnectorLeasePath(IConfigurationSession session, ADObjectId rootId, out string primaryLeasePath, out string backupLeasePath, out bool hasOneConnectorEnabledInCurrentForest)
        {
            string text;

            backupLeasePath  = (text = null);
            primaryLeasePath = text;
            hasOneConnectorEnabledInCurrentForest = false;
            EdgeSyncMservConnector edgeSyncMservConnector = base.FindSiteEdgeSyncConnector <EdgeSyncMservConnector>(session, rootId, out hasOneConnectorEnabledInCurrentForest);

            if (edgeSyncMservConnector == null)
            {
                return(false);
            }
            primaryLeasePath = Path.Combine(edgeSyncMservConnector.PrimaryLeaseLocation, "mserv.lease");
            backupLeasePath  = Path.Combine(edgeSyncMservConnector.BackupLeaseLocation, "mserv.lease");
            return(true);
        }
 private void InitializeClientToken()
 {
     if (string.IsNullOrEmpty(MserveTargetConnection.clientToken))
     {
         ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
         {
             MserveTargetConnection.clientToken = EdgeSyncMservConnector.GetMserveWebServiceClientTokenFromEndpointConfig(null);
             if (string.IsNullOrEmpty(MserveTargetConnection.clientToken))
             {
                 throw new ExDirectoryException("Client token from Endpoint configuration is null or empty", null);
             }
         }, 3);
         if (!adoperationResult.Succeeded)
         {
             throw new ExDirectoryException("Unable to read client token from Endpoint configuration", adoperationResult.Exception);
         }
     }
 }
Пример #6
0
 // Token: 0x06000989 RID: 2441 RVA: 0x00020DB7 File Offset: 0x0001EFB7
 public EdgeSyncMservConnectorIdParameter(EdgeSyncMservConnector connector) : base(connector.Id)
 {
 }
Пример #7
0
        // Token: 0x060003B6 RID: 950 RVA: 0x0001573C File Offset: 0x0001393C
        internal static ADObject CreateAndInitializeConfigObject <TConfigObject>(ADPropertyBag propertyBag, ADRawEntry dummyObject, IDirectorySession directorySession) where TConfigObject : IConfigurable, new()
        {
            ArgumentValidator.ThrowIfNull("propertyBag", propertyBag);
            MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)propertyBag[ADObjectSchema.ObjectClass];
            ADObject adobject;

            if (dummyObject is MiniTopologyServer)
            {
                adobject = new MiniTopologyServer();
            }
            else if (dummyObject is MiniVirtualDirectory)
            {
                adobject = new MiniVirtualDirectory();
            }
            else if (dummyObject is MiniEmailTransport)
            {
                adobject = new MiniEmailTransport();
            }
            else if (dummyObject is MiniReceiveConnector)
            {
                adobject = new MiniReceiveConnector();
            }
            else if (multiValuedProperty.Contains(ADWebServicesVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADWebServicesVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADE12UMVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADE12UMVirtualDirectory();
            }
            else if (multiValuedProperty.Contains("msExchMobileVirtualDirectory"))
            {
                adobject = new ADMobileVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADOwaVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADOwaVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADRpcHttpVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADRpcHttpVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADMapiVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADMapiVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADAvailabilityForeignConnectorVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADAvailabilityForeignConnectorVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADOabVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADOabVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(ADEcpVirtualDirectory.MostDerivedClass))
            {
                adobject = new ADEcpVirtualDirectory();
            }
            else if (multiValuedProperty.Contains(Pop3AdConfiguration.MostDerivedClass))
            {
                adobject = new Pop3AdConfiguration();
            }
            else if (multiValuedProperty.Contains(Imap4AdConfiguration.MostDerivedClass))
            {
                adobject = new Imap4AdConfiguration();
            }
            else if (multiValuedProperty.Contains("mailGateway"))
            {
                if (multiValuedProperty.Contains(SmtpSendConnectorConfig.MostDerivedClass))
                {
                    adobject = new SmtpSendConnectorConfig();
                }
                else if (multiValuedProperty.Contains(DeliveryAgentConnector.MostDerivedClass))
                {
                    adobject = new DeliveryAgentConnector();
                }
                else if (propertyBag.Contains(ForeignConnectorSchema.DropDirectory))
                {
                    adobject = new ForeignConnector();
                }
                else
                {
                    adobject = new LegacyGatewayConnector();
                }
            }
            else if (multiValuedProperty.Contains("msExchEdgeSyncEhfConnector"))
            {
                adobject = new EdgeSyncEhfConnector();
            }
            else
            {
                if (!multiValuedProperty.Contains("msExchEdgeSyncMservConnector"))
                {
                    return(ADObjectFactory.CreateAndInitializeObject <TConfigObject>(propertyBag, directorySession));
                }
                adobject = new EdgeSyncMservConnector();
            }
            adobject.m_Session   = directorySession;
            adobject.propertyBag = propertyBag;
            adobject.Initialize();
            adobject.ResetChangeTracking(true);
            if (directorySession != null)
            {
                adobject.SetIsReadOnly(directorySession.ReadOnly);
            }
            return(adobject);
        }
        private static List <RecipientSyncOperation> SyncToMserv(string address, RecipientSyncOperation operation)
        {
            int    num       = 0;
            int    partnerId = operation.PartnerId;
            string text      = (operation.AddedEntries.Count > 0) ? "Add" : ((operation.RemovedEntries.Count > 0) ? "Remove" : "Read");

            ExTraceGlobals.FaultInjectionTracer.TraceTest(4156960061U);
            ExTraceGlobals.FaultInjectionTracer.TraceTest(2546347325U);
            List <RecipientSyncOperation> result;

            for (;;)
            {
                bool      flag      = false;
                int       tickCount = Environment.TickCount;
                Exception ex        = null;
                List <RecipientSyncOperation> list = null;
                MserveWebService mserveWebService  = null;
                try
                {
                    mserveWebService = EdgeSyncMservConnector.CreateDefaultMserveWebService(null);
                    mserveWebService.TrackDuplicatedAddEntries = true;
                    flag = true;
                    ExTraceGlobals.MServTracer.TraceDebug <string, string, int>(0L, "Executing {0} for {1} with PartnerId = {2}", text, address, operation.PartnerId);
                    mserveWebService.Synchronize(operation);
                    list   = mserveWebService.Synchronize();
                    result = list;
                }
                catch (InvalidMserveRequestException ex2)
                {
                    ex = ex2;
                    throw new MServTransientException(DirectoryStrings.TransientMservError(ex2.Message));
                }
                catch (MserveException ex3)
                {
                    ex = (ex3.InnerException ?? ex3);
                    if (!MserveWebService.IsTransientException(ex3) && (ex3.InnerException == null || (!(ex3.InnerException is WebException) && !(ex3.InnerException is IOException) && !(ex3.InnerException is HttpWebRequestException) && !(ex3.InnerException is DownloadTimeoutException))))
                    {
                        throw new MServPermanentException(DirectoryStrings.PermanentMservError(ex.Message));
                    }
                    num++;
                    ExTraceGlobals.MServTracer.TraceWarning(0L, "Attempt {0}: got transient exception {1} for {2} ({3})", new object[]
                    {
                        num,
                        ex3.InnerException,
                        flag ? text : "MServeWebService creation",
                        address
                    });
                    if (num < MServDirectorySession.retriesAllowed)
                    {
                        continue;
                    }
                    throw new MServTransientException(DirectoryStrings.TransientMservError(ex.Message));
                }
                finally
                {
                    if (list != null && list.Count > 0 && text == "Read")
                    {
                        partnerId = list[0].PartnerId;
                    }
                    string failure = string.Empty;
                    int    num2    = Environment.TickCount - tickCount;
                    if (ex != null)
                    {
                        failure = ((ex.InnerException == null) ? ex.Message : ex.InnerException.ToString());
                    }
                    string diagnosticHeader = string.Empty;
                    string ipAddress        = string.Empty;
                    string transactionId    = string.Empty;
                    if (mserveWebService != null)
                    {
                        diagnosticHeader = (mserveWebService.LastResponseDiagnosticInfo ?? string.Empty);
                        ipAddress        = (mserveWebService.LastIpUsed ?? string.Empty);
                        transactionId    = (mserveWebService.LastResponseTransactionId ?? string.Empty);
                    }
                    MservProtocolLog.BeginAppend(text, (ex == null) ? "Success" : "Failure", (long)num2, failure, address, partnerId.ToString(), ipAddress, diagnosticHeader, transactionId);
                }
                break;
            }
            return(result);
        }