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));
            }
        }
        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);
        }