Ejemplo n.º 1
0
 private static TimeSpan DumpLogFiles()
 {
     using (List <ILogProcessable> .Enumerator enumerator = MRSService.scheduledLogsList.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             ILogProcessable scheduledLog = enumerator.Current;
             CommonUtils.CatchKnownExceptions(delegate
             {
                 MrsTracer.Service.Debug("Processing {0} MRS scheduled log", new object[]
                 {
                     scheduledLog.GetType().Name
                 });
                 scheduledLog.ProcessLogs();
             }, delegate(Exception ex)
             {
                 MrsTracer.Service.Debug("Exception occurred while processing {0} MRS scheduled log: {1}", new object[]
                 {
                     scheduledLog.GetType().Name,
                     ex.Message
                 });
             });
         }
     }
     return(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("MRSScheduledLogsCheckFrequency"));
 }
Ejemplo n.º 2
0
 private static TimeSpan PickLightJobs()
 {
     TestIntegration.Instance.Barrier("DontPickupJobs", null);
     CommonUtils.CatchKnownExceptions(delegate
     {
         DateTime utcNow = DateTime.UtcNow;
         if (utcNow > MRSService.nextLightJobsFullScanTime)
         {
             double num = CommonUtils.Randomize(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("FullScanLightJobsPollingPeriod").TotalSeconds, 0.2);
             MRSService.nextLightJobsFullScanTime = utcNow + TimeSpan.FromSeconds(num);
             MrsTracer.Service.Debug("Next light job full scan in {0} seconds, at {1}", new object[]
             {
                 (int)num,
                 MRSService.nextLightJobsFullScanTime
             });
             foreach (Guid mdbGuid in MapiUtils.GetDatabasesOnThisServer())
             {
                 MRSQueue.Get(mdbGuid).Tickle(MRSQueue.ScanType.Light);
             }
         }
         List <Guid> queuesToScan = MRSQueue.GetQueuesToScan(MRSQueue.ScanType.Light);
         if (queuesToScan != null)
         {
             foreach (Guid mdbGuid2 in queuesToScan)
             {
                 CommonUtils.CheckForServiceStopping();
                 MRSQueue.Get(mdbGuid2).PickupLightJobs();
             }
         }
     }, null);
     return(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("LightJobPickupPeriod"));
 }
Ejemplo n.º 3
0
        public MessageRecSorter()
        {
            this.maxFolderTolerance = MessageRecSorter.DefaultFolderTolerance;
            this.minBatchSize       = ConfigBase <MRSConfigSchema> .GetConfig <int>("MinBatchSize");

            this.minBatchByteSize = ConfigBase <MRSConfigSchema> .GetConfig <ulong>("MinBatchSizeKB") * 1024UL;
        }
Ejemplo n.º 4
0
        public static DatabaseInformation FindServerForMdb(ADObjectId database, string dcName, NetworkCredential cred, FindServerFlags flags)
        {
            if (!ConfigBase <MRSConfigSchema> .GetConfig <bool>("CrossResourceForestEnabled"))
            {
                return(MapiUtils.FindServerForMdb(database.ObjectGuid, dcName, cred, flags));
            }
            Guid empty = Guid.Empty;
            DatabaseInformation result;

            try
            {
                if (database.GetPartitionId().IsLocalForestPartition())
                {
                    result = MapiUtils.FindServerForMdb(database.ObjectGuid, dcName, cred, flags);
                }
                else
                {
                    BackEndServer backEndServer = BackEndLocator.GetBackEndServer(database);
                    result = DatabaseInformation.FromBackEndServer(database, backEndServer);
                }
            }
            catch (BackEndLocatorException)
            {
                MrsTracer.Common.Debug("BE Locator was unable to locate MDB {0}.", new object[]
                {
                    database.ObjectGuid
                });
                if ((flags & FindServerFlags.AllowMissing) == FindServerFlags.None)
                {
                    throw;
                }
                result = DatabaseInformation.Missing(database.ObjectGuid, database.PartitionFQDN);
            }
            return(result);
        }
Ejemplo n.º 5
0
 internal static ADObjectId ResolveDNIfNecessary(ADObjectId obj)
 {
     if (ADSessionSettings.IsRunningOnCmdlet() || ConfigBase <AdDriverConfigSchema> .GetConfig <bool>("IsSoftLinkResolutionEnabledForAllProcesses"))
     {
         return(ADObjectIdResolutionHelper.ResolveDN(obj));
     }
     return(obj);
 }
Ejemplo n.º 6
0
 protected virtual void ScheduleIncrementalSync()
 {
     if (this.IsInteractive)
     {
         base.ScheduleWorkItem(new PeriodicWorkItem(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("ActivatedJobIncrementalSyncInterval"), new Action(this.IncrementalSync)));
         return;
     }
     base.ScheduleWorkItem(new Action(this.IncrementalSync), WorkloadType.Unknown);
 }
Ejemplo n.º 7
0
 private static TimeSpan PickHeavyJobs()
 {
     TestIntegration.Instance.Barrier("DontPickupJobs", null);
     CommonUtils.CatchKnownExceptions(delegate
     {
         DateTime utcNow = DateTime.UtcNow;
         bool flag       = false;
         TimeSpan config = ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("ADInconsistencyCleanUpPeriod");
         if (config != TimeSpan.Zero && MRSService.lastADCleanUpScanFinishTime != null)
         {
             DateTime t = utcNow;
             if (t >= MRSService.lastADCleanUpScanFinishTime + config)
             {
                 ThreadPool.QueueUserWorkItem(new WaitCallback(MRSService.CleanADOprhanAndInconsistency));
             }
         }
         ReservationManager.UpdateHealthState();
         if (utcNow >= MRSService.NextFullScanTime)
         {
             MailboxReplicationServicePerformanceCounters.LastScanTime.RawValue = CommonUtils.TimestampToPerfcounterLong(utcNow);
             MRSService.lastFullScanTime = utcNow;
             flag         = true;
             double value = CommonUtils.Randomize(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("FullScanMoveJobsPollingPeriod").TotalSeconds, 0.2);
             MRSService.NextFullScanTime = utcNow + TimeSpan.FromSeconds(value);
             MrsTracer.Service.Debug("Next full scan at {0}", new object[]
             {
                 MRSService.NextFullScanTime
             });
             foreach (Guid mdbGuid in MapiUtils.GetDatabasesOnThisServer())
             {
                 MRSQueue.Get(mdbGuid).Tickle(MRSQueue.ScanType.Heavy);
             }
         }
         int num = 0;
         List <Guid> queuesToScan = MRSQueue.GetQueuesToScan(MRSQueue.ScanType.Heavy);
         if (queuesToScan != null)
         {
             foreach (Guid mdbGuid2 in queuesToScan)
             {
                 CommonUtils.CheckForServiceStopping();
                 bool flag2;
                 MRSQueue.Get(mdbGuid2).PickupHeavyJobs(out flag2);
                 if (flag2)
                 {
                     num++;
                 }
             }
         }
         if (flag)
         {
             MRSService.lastFullScanDuration = (long)(DateTime.UtcNow - utcNow).TotalMilliseconds;
             MailboxReplicationServicePerformanceCounters.LastScanDuration.RawValue     = MRSService.lastFullScanDuration;
             MailboxReplicationServicePerformanceCounters.UnreachableDatabases.RawValue = (long)num;
         }
     }, null);
     return(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("HeavyJobPickupPeriod"));
 }
        // Token: 0x0600061B RID: 1563 RVA: 0x000211EC File Offset: 0x0001F3EC
        internal static bool UseAggregateSession(ADSessionSettings sessionSettings)
        {
            ADServerSettings externalServerSettings = ADSessionSettings.ExternalServerSettings;
            ADDriverContext  processADContext       = ADSessionSettings.GetProcessADContext();
            bool             flag  = processADContext != null && processADContext.Mode == ContextMode.Setup;
            bool             flag2 = externalServerSettings != null && externalServerSettings.ForceADInTemplateScope;
            bool             flag3 = !ConfigBase <AdDriverConfigSchema> .GetConfig <bool>("ConsumerMailboxScenarioDisabled");

            return(flag3 && TemplateTenantConfiguration.IsTemplateTenant(sessionSettings.CurrentOrganizationId) && !sessionSettings.ForceADInTemplateScope && !flag2 && !flag);
        }
Ejemplo n.º 9
0
        private static ADObjectId ResolveADObject(ADObjectId obj)
        {
            bool config = ConfigBase <AdDriverConfigSchema> .GetConfig <bool>("IsSoftLinkResolutionCacheEnabled");

            if (config)
            {
                return(ADObjectIdResolutionCache.Default.GetEntry(obj));
            }
            return(ADObjectIdResolutionHelper.ResolveADObjectIdWithoutCache(obj));
        }
Ejemplo n.º 10
0
            private bool IsTraceLoggingEnabled(TraceType traceType)
            {
                string config = ConfigBase <MRSConfigSchema> .GetConfig <string>("TraceLogLevels");

                if (!CommonUtils.IsValueInWildcardedList(traceType.ToString(), config))
                {
                    return(false);
                }
                string config2 = ConfigBase <MRSConfigSchema> .GetConfig <string>("TraceLogTracers");

                return(CommonUtils.IsValueInWildcardedList(this.Name, config2));
            }
Ejemplo n.º 11
0
 public void Deactivate(Guid mailboxGuid)
 {
     lock (this.locker)
     {
         this.activeMailboxes.Remove(mailboxGuid);
         this.disconnectOrphanedSessionActions.Remove(mailboxGuid);
         if (this.activeMailboxes.Count == 0)
         {
             this.expirationTimestamp = DateTime.UtcNow + ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("ReservationExpirationInterval");
         }
     }
 }
Ejemplo n.º 12
0
 private void SetSkipMergingAndInternalFlags(TransactionalRequestJob dataObject)
 {
     RequestTaskHelper.SetSkipMerging(this.SkipMerging, dataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
     RequestTaskHelper.SetInternalFlags(this.InternalFlags, dataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
     if (this.SkipMerging == null)
     {
         using (SettingsContextBase.ActivateContext(dataObject))
         {
             dataObject.SkipKnownCorruptions = ConfigBase <MRSConfigSchema> .GetConfig <bool>("SkipKnownCorruptionsDefault");
         }
     }
 }
        // Token: 0x06000DD7 RID: 3543 RVA: 0x0003FE2C File Offset: 0x0003E02C
        private void ConvertComparisonFilter(ComparisonFilter comparisonFilter, QueryFilter parentFilter)
        {
            ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)comparisonFilter.Property;

            if (adpropertyDefinition != ADObjectSchema.ObjectCategory)
            {
                this.containsUnsafeIdentity |= adpropertyDefinition.IsForestSpecific;
            }
            if (!adpropertyDefinition.IsSoftLinkAttribute)
            {
                this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, false, 0);
                return;
            }
            bool config = ConfigBase <AdDriverConfigSchema> .GetConfig <bool>("SoftLinkFilterVersion2Enabled");

            switch (this.softLinkMode)
            {
            case SoftLinkMode.Enabled:
                if (config)
                {
                    this.IncrementFilterSize(2);
                    this.ldapFilter.Append("(|");
                    this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, true, 1);
                    this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, true, 2);
                    this.ldapFilter.Append(")");
                    return;
                }
                this.IncrementFilterSize();
                this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, true, 1);
                return;

            case SoftLinkMode.Disabled:
                this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, false, 0);
                return;
            }
            if (config)
            {
                this.IncrementFilterSize(3);
                this.ldapFilter.Append("(|");
                this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, false, 0);
                this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, true, 1);
                this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, true, 2);
                this.ldapFilter.Append(")");
                return;
            }
            this.IncrementFilterSize(2);
            this.ldapFilter.Append("(|");
            this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, false, 0);
            this.ConvertComparisonFilterInternal(comparisonFilter, parentFilter, true, 1);
            this.ldapFilter.Append(")");
        }
Ejemplo n.º 14
0
        public RemoteMailbox(string serverName, string remoteOrgName, NetworkCredential remoteCred, ProxyControlFlags proxyControlFlags, IEnumerable <MRSProxyCapabilities> requiredCapabilities, bool useHttps, LocalMailboxFlags flags) : base(null, 0L)
        {
            this.serverName           = serverName;
            this.remoteOrgName        = remoteOrgName;
            this.remoteCred           = remoteCred;
            this.proxyControlFlags    = proxyControlFlags;
            this.requiredCapabilities = requiredCapabilities;
            this.useHttps             = useHttps;
            this.flags = flags;
            TestIntegration.Instance.ForceRefresh();
            this.longOperationTimeout = ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("MRSProxyLongOperationTimeout");

            this.ExportBufferSizeKB = ConfigBase <MRSConfigSchema> .GetConfig <int>("ExportBufferSizeKB");
        }
        public static MailboxReplicationServiceClient Create(string serverName, MRSCapabilities requiredCapability)
        {
            MrsTracer.Common.Debug("MRSClient: attempting to connect to '{0}'", new object[]
            {
                serverName
            });
            string        text          = string.Format("net.tcp://{0}/Microsoft.Exchange.MailboxReplicationService", serverName);
            NetTcpBinding netTcpBinding = new NetTcpBinding(SecurityMode.Transport);

            netTcpBinding.Security.Transport.ProtectionLevel      = ProtectionLevel.EncryptAndSign;
            netTcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
            netTcpBinding.Security.Message.ClientCredentialType   = MessageCredentialType.Windows;
            int config = ConfigBase <MRSConfigSchema> .GetConfig <int>("MrsBindingMaxMessageSize");

            netTcpBinding.MaxReceivedMessageSize = (long)config;
            netTcpBinding.ReaderQuotas.MaxStringContentLength = config;
            netTcpBinding.ReaderQuotas.MaxArrayLength         = config;
            EndpointAddress remoteAddress;

            try
            {
                remoteAddress = new EndpointAddress(text);
            }
            catch (UriFormatException innerException)
            {
                throw new InvalidEndpointAddressPermanentException(text, innerException);
            }
            MailboxReplicationServiceClient mailboxReplicationServiceClient = null;
            bool flag = false;

            try
            {
                mailboxReplicationServiceClient = new MailboxReplicationServiceClient(netTcpBinding, remoteAddress);
                mailboxReplicationServiceClient.ExchangeVersionInformation(requiredCapability);
                flag = true;
            }
            finally
            {
                if (!flag && mailboxReplicationServiceClient != null)
                {
                    mailboxReplicationServiceClient.Dispose();
                }
            }
            MrsTracer.Common.Debug("MRSClient: connected to '{0}', version {1}", new object[]
            {
                mailboxReplicationServiceClient.ServerVersion.ComputerName,
                mailboxReplicationServiceClient.ServerVersion
            });
            return(mailboxReplicationServiceClient);
        }
Ejemplo n.º 16
0
        protected void RefreshFolderCache(EasHierarchySyncState state)
        {
            IReadOnlyCollection <Add> folders    = state.Folders;
            EntryIdMap <Add>          entryIdMap = new EntryIdMap <Add>(folders.Count);

            this.defaultCalendarId = null;
            foreach (Add add in folders)
            {
                EasFolderType easFolderType = add.GetEasFolderType();
                if (easFolderType == EasFolderType.Calendar)
                {
                    this.defaultCalendarId = EasMailbox.GetEntryId(add.ServerId);
                }
                EasFolderType easFolderType2 = easFolderType;
                if (easFolderType2 == EasFolderType.UserGeneric)
                {
                    goto IL_8B;
                }
                bool flag;
                switch (easFolderType2)
                {
                case EasFolderType.Contacts:
                case EasFolderType.UserContacts:
                    flag = !ConfigBase <MRSConfigSchema> .GetConfig <bool>("DisableContactSync");

                    goto IL_9D;

                case EasFolderType.UserMail:
                case EasFolderType.UserCalendar:
                    goto IL_8B;
                }
                flag = EasMailbox.folderTypeMap.ContainsKey(easFolderType);
IL_9D:
                if (flag)
                {
                    entryIdMap.Add(EasMailbox.GetEntryId(add.ServerId), add);
                    continue;
                }
                MrsTracer.Provider.Debug("EasMailbox.RefreshFolderCache: ignore {0} folder '{1}' since it is not supported yet", new object[]
                {
                    easFolderType,
                    add.DisplayName
                });
                continue;
IL_8B:
                flag = true;
                goto IL_9D;
            }
            this.EasFolderCache = entryIdMap;
        }
Ejemplo n.º 17
0
        public static ITopologyConfigurationSession GetConfigSessionForDatabase(ITopologyConfigurationSession originalConfigSession, ADObjectId database)
        {
            ITopologyConfigurationSession result = originalConfigSession;

            if (database != null && ConfigBase <MRSConfigSchema> .GetConfig <bool>("CrossResourceForestEnabled"))
            {
                PartitionId partitionId = database.GetPartitionId();
                if (!partitionId.IsLocalForestPartition())
                {
                    ADSessionSettings sessionSettings = ADSessionSettings.FromAccountPartitionRootOrgScopeSet(partitionId);
                    result = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(null, true, ConsistencyMode.PartiallyConsistent, null, sessionSettings, 612, "GetConfigSessionForDatabase", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MailboxReplication\\RequestBase\\RequestTaskHelper.cs");
                }
            }
            return(result);
        }
Ejemplo n.º 18
0
 protected override void ScheduleIncrementalSync()
 {
     if (base.MailboxMerger.CanReplay && this.GetActionsPageSize > 0)
     {
         if (this.IsInteractive)
         {
             base.ScheduleWorkItem(new PeriodicWorkItem(ConfigBase <MRSConfigSchema> .GetConfig <TimeSpan>("ActivatedJobIncrementalSyncInterval"), new Action(this.ReplayActions)));
         }
         else
         {
             base.ScheduleWorkItem(new Action(this.ReplayActions), WorkloadType.Unknown);
         }
     }
     base.ScheduleIncrementalSync();
 }
        public static void Initialize()
        {
            if (ExchangeCertificateValidator.isInitialized)
            {
                return;
            }
            lock (ExchangeCertificateValidator.locker)
            {
                if (!ExchangeCertificateValidator.isInitialized)
                {
                    using (RegistryKey registryKey = ExchangeCertificateValidator.SafeOpenKey())
                    {
                        if (registryKey != null)
                        {
                            object value = registryKey.GetValue("AllowInternalUntrustedCerts");
                            if (value is int)
                            {
                                ExchangeCertificateValidator.allowInternalUntrustedCerts = ((int)value != 0);
                            }
                            value = registryKey.GetValue("AllowCertificateNameMismatchForMRS");
                            if (value is string[])
                            {
                                string[] values = (string[])value;
                                ExchangeCertificateValidator.AddToList(ExchangeCertificateValidator.TrustedSubjects, values);
                            }
                        }
                    }
                    string config = ConfigBase <MRSConfigSchema> .GetConfig <string>("ProxyClientTrustedCertificateThumbprints");

                    if (!string.IsNullOrWhiteSpace(config))
                    {
                        ExchangeCertificateValidator.AddToList(ExchangeCertificateValidator.TrustedThumbprints, config.Split(new char[]
                        {
                            ','
                        }));
                    }
                    if (ExchangeCertificateValidator.allowInternalUntrustedCerts || ExchangeCertificateValidator.TrustedSubjects.Count > 0 || ExchangeCertificateValidator.TrustedThumbprints.Count > 0)
                    {
                        ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ExchangeCertificateValidator.CertificateValidatorCallback);
                    }
                    else
                    {
                        ServicePointManager.ServerCertificateValidationCallback = null;
                    }
                    ExchangeCertificateValidator.isInitialized = true;
                }
            }
        }
Ejemplo n.º 20
0
        public ConfigBase Resolve(Type t)
        {
            if (t.IsSubclassOf(typeof(ConfigBase)))
            {
                return(ConfigBase.GetConfig(t));
            }

            string key = t.Assembly.FullName;

            if (types.ContainsKey(key))
            {
                return(ConfigBase.GetConfig(types[key]));
            }

            return(null);
        }
Ejemplo n.º 21
0
        private bool IsCertificateAuthentication(OperationContext operationContext)
        {
            if (!ConfigBase <MRSConfigSchema> .GetConfig <bool>("ProxyServiceCertificateEndpointEnabled"))
            {
                return(false);
            }
            ServiceSecurityContext serviceSecurityContext = operationContext.ServiceSecurityContext;

            if (serviceSecurityContext == null || serviceSecurityContext.AuthorizationContext == null || serviceSecurityContext.AuthorizationContext.ClaimSets == null || serviceSecurityContext.AuthorizationContext.ClaimSets.Count != 1)
            {
                return(false);
            }
            X509CertificateClaimSet x509CertificateClaimSet = serviceSecurityContext.AuthorizationContext.ClaimSets[0] as X509CertificateClaimSet;

            return(x509CertificateClaimSet != null && !(x509CertificateClaimSet.X509Certificate.Subject != ConfigBase <MRSConfigSchema> .GetConfig <string>("ProxyClientCertificateSubject")));
        }
Ejemplo n.º 22
0
        private int GetExportBufferSize(int exportBufferSizeFromMrsKB)
        {
            int num = ConfigBase <MRSConfigSchema> .GetConfig <int>("ExportBufferSizeOverrideKB");

            if (num == 0)
            {
                if (exportBufferSizeFromMrsKB > 0)
                {
                    num = exportBufferSizeFromMrsKB;
                }
                else
                {
                    num = ConfigBase <MRSConfigSchema> .GetConfig <int>("ExportBufferSizeKB");
                }
            }
            return(num * 1024);
        }
Ejemplo n.º 23
0
        private void InitializeFromConfig()
        {
            this.LastRefreshed = ConfigBase <OlcConfigSchema> .Provider.LastUpdated;
            string config = ConfigBase <OlcConfigSchema> .GetConfig <string>("OlcTopology");

            if (config == null)
            {
                this.xml = null;
                return;
            }
            XDocument xdocument = OlcTopology.Deserialize(config);

            if (xdocument != null)
            {
                Interlocked.Exchange <XDocument>(ref this.xml, xdocument);
            }
        }
Ejemplo n.º 24
0
        private SecurityIdentifier[] GetAdditionalSids()
        {
            string config = ConfigBase <MRSConfigSchema> .GetConfig <string>("AdditionalSidsForMrsProxyAuthorization");

            if (string.IsNullOrWhiteSpace(config))
            {
                return(Array <SecurityIdentifier> .Empty);
            }
            string[] array = config.Split(new char[]
            {
                ','
            });
            List <SecurityIdentifier> list = new List <SecurityIdentifier>(array.Length);

            foreach (string text in array)
            {
                if (!string.IsNullOrWhiteSpace(text))
                {
                    try
                    {
                        list.Add(new SecurityIdentifier(text));
                    }
                    catch (ArgumentException ex)
                    {
                        CommonUtils.LogEvent(MRSEventLogConstants.Tuple_ServiceConfigCorrupt, new object[]
                        {
                            CommonUtils.FullExceptionMessage(ex)
                        });
                        MrsTracer.ProxyService.Debug("MRSProxyAuthorizationManager.GetAdditionalSids: Cannot parse SID '{0}'. Skipping.", new object[]
                        {
                            text
                        });
                    }
                }
            }
            if (list.Count == 0)
            {
                return(Array <SecurityIdentifier> .Empty);
            }
            return(list.ToArray());
        }
Ejemplo n.º 25
0
        private static void WriteInternal(Guid requestGuid, Exception failure, bool isFatal, RequestState requestState, SyncStage syncStage, string folderName, string operationType, Guid failureGuid, int failureLevel)
        {
            FailureData objectToLog = default(FailureData);

            objectToLog.FailureGuid   = failureGuid;
            objectToLog.RequestGuid   = requestGuid;
            objectToLog.Failure       = failure;
            objectToLog.FailureLevel  = failureLevel;
            objectToLog.IsFatal       = isFatal;
            objectToLog.RequestState  = requestState;
            objectToLog.SyncStage     = syncStage;
            objectToLog.FolderName    = folderName;
            objectToLog.OperationType = operationType;
            if (objectToLog.OperationType == null && objectToLog.Failure != null)
            {
                string dataContext = ExecutionContext.GetDataContext(failure);
                objectToLog.OperationType = FailureLog.GetDataContextToPersist(dataContext);
            }
            GenericSettingsContext genericSettingsContext = new GenericSettingsContext("FailureType", CommonUtils.GetFailureType(failure), null);

            using (genericSettingsContext.Activate())
            {
                if (ConfigBase <MRSConfigSchema> .GetConfig <bool>("SendGenericWatson"))
                {
                    string watsonHash;
                    CommonUtils.SendGenericWatson(failure, CommonUtils.FullFailureMessageWithCallStack(failure, 5), out watsonHash);
                    objectToLog.WatsonHash = watsonHash;
                }
                else
                {
                    objectToLog.WatsonHash = CommonUtils.ComputeCallStackHash(failure, 5);
                }
            }
            FailureLog.instance.LogObject(objectToLog);
            if (failure.InnerException != null)
            {
                FailureLog.WriteInternal(requestGuid, failure.InnerException, isFatal, requestState, syncStage, folderName, operationType, failureGuid, failureLevel + 1);
            }
        }
Ejemplo n.º 26
0
        public static IMailboxReplicationProxyService CreateChannel(MailboxReplicationProxyClient proxyClient)
        {
            ChannelFactory <IMailboxReplicationProxyService> channelFactory = proxyClient.ChannelFactory;
            EndpointAddress address = proxyClient.Endpoint.Address;

            if (address.Uri != null && (address.Uri.Scheme == Uri.UriSchemeHttps || address.Uri.Scheme == Uri.UriSchemeHttp))
            {
                if (!ExchangeSessionAwareClientsHelper.webRequestCreator.IsDisabled)
                {
                    UriBuilder uriBuilder = new UriBuilder(address.Uri);
                    uriBuilder.Path = proxyClient.RequestContext.Id.ToString();
                    if (proxyClient.UseCertificateToAuthenticate)
                    {
                        string config = ConfigBase <MRSConfigSchema> .GetConfig <string>("ProxyClientCertificateSubject");

                        try
                        {
                            channelFactory.Credentials.ClientCertificate.Certificate = TlsCertificateInfo.FindFirstCertWithSubjectDistinguishedName(config, false);
                        }
                        catch (ArgumentException ex)
                        {
                            throw new CertificateLoadErrorException(config, ex.Message, ex);
                        }
                    }
                    return(channelFactory.CreateChannel(address, uriBuilder.Uri));
                }
                CustomBinding customBinding = channelFactory.Endpoint.Binding as CustomBinding;
                if (customBinding != null)
                {
                    HttpsTransportBindingElement httpsTransportBindingElement = customBinding.Elements.Find <HttpsTransportBindingElement>();
                    if (httpsTransportBindingElement != null)
                    {
                        httpsTransportBindingElement.AllowCookies = true;
                    }
                }
            }
            return(channelFactory.CreateChannel(address));
        }
Ejemplo n.º 27
0
        public static void FilterPropertyDefinitionsByBackendSource(IEnumerable <PropertyDefinition> properties, MbxReadMode mbxReadMode, out List <ADPropertyDefinition> adProps, out List <MServPropertyDefinition> mservProps, out List <MbxPropertyDefinition> mbxProps)
        {
            adProps    = new List <ADPropertyDefinition>();
            mservProps = new List <MServPropertyDefinition>();
            mbxProps   = new List <MbxPropertyDefinition>();
            bool flag = !ConfigBase <AdDriverConfigSchema> .GetConfig <bool>("ConsumerMbxLookupDisabled");

            foreach (PropertyDefinition propertyDefinition in properties)
            {
                ADPropertyDefinition adpropertyDefinition = propertyDefinition as ADPropertyDefinition;
                if (propertyDefinition != null)
                {
                    if (adpropertyDefinition.MServPropertyDefinition != null)
                    {
                        mservProps.Add((MServPropertyDefinition)adpropertyDefinition.MServPropertyDefinition);
                    }
                    if (adpropertyDefinition.MbxPropertyDefinition != null && mbxReadMode != MbxReadMode.NoMbxRead && flag)
                    {
                        mbxProps.Add((MbxPropertyDefinition)adpropertyDefinition.MbxPropertyDefinition);
                    }
                    adProps.Add(adpropertyDefinition);
                }
            }
        }
Ejemplo n.º 28
0
        private static TimeSpan CalculateCacheItemExpirationWindow(bool dataFromOfflineService, string tenantName, Guid externalOrgId, PartitionId accountPartitionId)
        {
            if (dataFromOfflineService)
            {
                return(TimeSpan.FromMinutes((double)ConfigBase <AdDriverConfigSchema> .GetConfig <int>("OfflineDataCacheExpirationTimeInMinutes")));
            }
            if (!ForestTenantRelocationsCache.IsTenantRelocationAllowed(accountPartitionId.ForestFQDN))
            {
                return(ExpiringTenantRelocationStateValue.TenantRelocationStateExpirationWindowProvider.DefaultExpirationWindow);
            }
            if (!string.IsNullOrEmpty(tenantName))
            {
                return(TenantRelocationStateCache.GetTenantCacheExpirationWindow(tenantName, accountPartitionId));
            }
            ITenantConfigurationSession tenantConfigurationSession            = DirectorySessionFactory.Default.CreateTenantConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsPartitionId(accountPartitionId), 110, "CalculateCacheItemExpirationWindow", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\TenantPartitionCacheItem.cs");
            ExchangeConfigurationUnit   exchangeConfigurationUnitByExternalId = tenantConfigurationSession.GetExchangeConfigurationUnitByExternalId(externalOrgId);

            if (exchangeConfigurationUnitByExternalId != null)
            {
                tenantName = ((ADObjectId)exchangeConfigurationUnitByExternalId.Identity).Parent.Name;
                return(TenantRelocationStateCache.GetTenantCacheExpirationWindow(tenantName, accountPartitionId));
            }
            return(ExpiringTenantRelocationStateValue.TenantRelocationStateExpirationWindowProvider.DefaultExpirationWindow);
        }
Ejemplo n.º 29
0
 // Token: 0x06000EF9 RID: 3833 RVA: 0x000482E8 File Offset: 0x000464E8
 public MservRecipientSession(bool isReadOnly = true)
 {
     this.isReadOnly          = isReadOnly;
     this.mservEndpointConfig = ((MservRecipientSession.mservEndPoint != null) ? MservRecipientSession.mservEndPoint : ConfigBase <AdDriverConfigSchema> .GetConfig <string>("MservEndpoint"));
     this.mservClient         = this.BuildMservClient(this.mservEndpointConfig);
 }
Ejemplo n.º 30
0
        protected override ICollection <ServiceIssue> RunFullIssueScan()
        {
            ICollection <ServiceIssue> collection = new List <ServiceIssue>();

            foreach (Guid mdbGuid in MapiUtils.GetDatabasesOnThisServer())
            {
                using (new DatabaseSettingsContext(mdbGuid, null).Activate())
                {
                    try
                    {
                        DatabaseInformation databaseInformation = MapiUtils.FindServerForMdb(mdbGuid, null, null, FindServerFlags.None);
                        string databaseName = databaseInformation.DatabaseName;
                        if (!databaseInformation.IsOnThisServer)
                        {
                            return(null);
                        }
                        using (MapiStore systemMailbox = MapiUtils.GetSystemMailbox(mdbGuid, false))
                        {
                            using (MapiFolder requestJobsFolder = RequestJobXML.GetRequestJobsFolder(systemMailbox))
                            {
                                using (MapiTable contentsTable = requestJobsFolder.GetContentsTable(ContentsTableFlags.DeferredErrors))
                                {
                                    if (contentsTable.GetRowCount() > 0)
                                    {
                                        RequestJobNamedPropertySet requestJobNamedPropertySet = RequestJobNamedPropertySet.Get(systemMailbox);
                                        contentsTable.SetColumns(requestJobNamedPropertySet.PropTags);
                                        Restriction    restriction = Restriction.GT(requestJobNamedPropertySet.PropTags[23], ConfigBase <MRSConfigSchema> .GetConfig <int>("PoisonLimit"));
                                        List <MoveJob> allMoveJobs = SystemMailboxJobs.GetAllMoveJobs(restriction, null, contentsTable, mdbGuid, null);
                                        if (allMoveJobs != null)
                                        {
                                            foreach (MoveJob job in allMoveJobs)
                                            {
                                                collection.Add(new MRSPoisonedJobIssue(job));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (LocalizedException lastScanError)
                    {
                        base.LastScanError = lastScanError;
                    }
                }
            }
            return(collection);
        }