コード例 #1
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));
            }
        }
コード例 #2
0
        internal static MserveWebService CreateDefaultMserveWebService(string domainController, bool batchMode, int initialChunkSize)
        {
            ITopologyConfigurationSession rootOrgSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainController, true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 200, "CreateDefaultMserveWebService", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\EdgeSyncMservConnector.cs");
            EdgeSyncServiceConfig         config         = null;
            string            clientToken       = null;
            ADSite            localSite         = null;
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                localSite = rootOrgSession.GetLocalSite();
                if (localSite == null)
                {
                    throw new TransientException(DirectoryStrings.CannotGetLocalSite);
                }
                config      = rootOrgSession.Read <EdgeSyncServiceConfig>(localSite.Id.GetChildId("EdgeSyncService"));
                clientToken = EdgeSyncMservConnector.GetMserveWebServiceClientTokenFromEndpointConfig(rootOrgSession);
            }, 3);

            if (!adoperationResult.Succeeded)
            {
                throw adoperationResult.Exception;
            }
            if (config == null)
            {
                throw new MserveException(string.Format("No EdgeSync configuration found. Site {0}", localSite.DistinguishedName));
            }
            if (string.IsNullOrEmpty(clientToken))
            {
                throw new InvalidOperationException(string.Format("clientToken from Endpoint configuration is null or empty . Site {0}", localSite.DistinguishedName));
            }
            List <EdgeSyncMservConnector> connectors = new List <EdgeSyncMservConnector>();

            if (!ADNotificationAdapter.TryReadConfigurationPaged <EdgeSyncMservConnector>(() => rootOrgSession.FindPaged <EdgeSyncMservConnector>(config.Id, QueryScope.SubTree, null, null, 0), delegate(EdgeSyncMservConnector connector)
            {
                connectors.Add(connector);
            }, 3, out adoperationResult))
            {
                throw adoperationResult.Exception;
            }
            if (connectors.Count == 0)
            {
                throw new InvalidOperationException(string.Format("No MServ configuration found. Site {0}", localSite.DistinguishedName));
            }
            MserveWebService mserveWebService = new MserveWebService(connectors[0].ProvisionUrl.AbsoluteUri, connectors[0].SettingUrl.AbsoluteUri, connectors[0].RemoteCertificate, clientToken, batchMode);

            mserveWebService.Initialize(initialChunkSize);
            return(mserveWebService);
        }
コード例 #3
0
        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);
        }