Пример #1
0
        // Token: 0x06000675 RID: 1653 RVA: 0x00017E78 File Offset: 0x00016078
        bool IWritableAD.SetDatabaseLegacyDnAndOwningServer(Guid mdbGuid, AmServerName lastMountedServerName, AmServerName masterServerName, bool isForceUpdate)
        {
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 43, "SetDatabaseLegacyDnAndOwningServer", "f:\\15.00.1497\\sources\\dev\\cluster\\src\\Shared\\WritableADHelper.cs");
            Database database = topologyConfigurationSession.FindDatabaseByGuid <Database>(mdbGuid);

            if (database == null)
            {
                AmTrace.Error("Failed to find Db using dbGuid {0}", new object[]
                {
                    mdbGuid
                });
                return(false);
            }
            MiniServer miniServer = topologyConfigurationSession.FindMiniServerByName(masterServerName.NetbiosName, WritableADHelper.s_propertiesNeededFromServer);

            if (miniServer == null)
            {
                AmTrace.Error("Failed to find Server using {0}", new object[]
                {
                    masterServerName
                });
                return(false);
            }
            if (isForceUpdate || !database.Server.Equals(miniServer.Id))
            {
                MiniServer sourceServer = null;
                if (!AmServerName.IsNullOrEmpty(lastMountedServerName))
                {
                    sourceServer = topologyConfigurationSession.FindMiniServerByName(lastMountedServerName.NetbiosName, WritableADHelper.s_propertiesNeededFromServer);
                }
                AmTrace.Debug("SetDatabaseLegacyDnAndOwningServer. Database '{0}', legdn='{1}'. Setting owning server: '{2}'.", new object[]
                {
                    database.Name,
                    database.ExchangeLegacyDN,
                    miniServer.Id
                });
                database.Server = miniServer.Id;
                WritableADHelper.SaveDatabasePropertiesOnMultipleServerSites(topologyConfigurationSession, database, sourceServer, miniServer, true);
                return(true);
            }
            AmTrace.Debug("Skipped to update legacy dn and owning server for database '{0}' since they are up to date. (owningserver={1})", new object[]
            {
                database.Name,
                database.Server
            });
            return(false);
        }
Пример #2
0
        // Token: 0x06000676 RID: 1654 RVA: 0x00017FA4 File Offset: 0x000161A4
        void IWritableAD.ResetAllowFileRestoreDsFlag(Guid mdbGuid, AmServerName lastMountedServerName, AmServerName masterServerName)
        {
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 108, "ResetAllowFileRestoreDsFlag", "f:\\15.00.1497\\sources\\dev\\cluster\\src\\Shared\\WritableADHelper.cs");
            Database database = topologyConfigurationSession.FindDatabaseByGuid <Database>(mdbGuid);

            if (database == null)
            {
                AmTrace.Error("Failed to find Db using dbGuid {0}", new object[]
                {
                    mdbGuid
                });
                return;
            }
            if (!database.AllowFileRestore)
            {
                AmTrace.Debug("Skipped to update legacy AllowFileRestore database '{0}'.)", new object[]
                {
                    database.Name
                });
                return;
            }
            MiniServer miniServer = topologyConfigurationSession.FindMiniServerByName(masterServerName.NetbiosName, WritableADHelper.s_propertiesNeededFromServer);

            if (miniServer == null)
            {
                AmTrace.Error("Failed to find Server using {0}", new object[]
                {
                    masterServerName
                });
                return;
            }
            MiniServer sourceServer = null;

            if (!AmServerName.IsNullOrEmpty(lastMountedServerName))
            {
                sourceServer = topologyConfigurationSession.FindMiniServerByName(lastMountedServerName.NetbiosName, WritableADHelper.s_propertiesNeededFromServer);
            }
            AmTrace.Debug("Reset AllowFileRestore. Database '{0}', legdn='{1}'. Setting owning server: '{2}'.", new object[]
            {
                database.Name,
                database.ExchangeLegacyDN,
                miniServer.Id
            });
            database.AllowFileRestore = false;
            WritableADHelper.SaveDatabasePropertiesOnMultipleServerSites(topologyConfigurationSession, database, sourceServer, miniServer, true);
        }
Пример #3
0
        // Token: 0x06000076 RID: 118 RVA: 0x000031F8 File Offset: 0x000013F8
        private DateTime GetBootTimeWithWmi(ManagementClass mgmtClass, AmServerName machineName)
        {
            DateTime  dateTime = ExDateTime.Now.UniversalTime;
            Exception ex       = null;

            try
            {
                using (ManagementObjectCollection instances = mgmtClass.GetInstances())
                {
                    if (instances != null)
                    {
                        using (ManagementObjectCollection.ManagementObjectEnumerator enumerator = instances.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                ManagementBaseObject managementBaseObject = enumerator.Current;
                                ManagementObject     managementObject     = (ManagementObject)managementBaseObject;
                                using (managementObject)
                                {
                                    string dmtfDate = (string)managementObject["LastBootupTime"];
                                    dateTime = ManagementDateTimeConverter.ToDateTime(dmtfDate).ToUniversalTime();
                                    AmTrace.Debug("GetBootTimeWithWmi: WMI says that the boot time for {0} is {1}.", new object[]
                                    {
                                        machineName,
                                        dateTime
                                    });
                                }
                            }
                            goto IL_102;
                        }
                    }
                    AmTrace.Error("GetBootTimeWithWmi: WMI could not query the boot time on server {0}: No instances found for management path {1}.", new object[]
                    {
                        machineName,
                        mgmtClass.ClassPath.Path
                    });
                    ReplayEventLogConstants.Tuple_GetBootTimeWithWmiFailure.LogEvent(string.Empty, new object[]
                    {
                        machineName,
                        Strings.NoInstancesFoundForManagementPath(mgmtClass.ClassPath.Path)
                    });
                    IL_102 :;
                }
            }
            catch (COMException ex2)
            {
                ex = ex2;
            }
            catch (UnauthorizedAccessException ex3)
            {
                ex = ex3;
            }
            catch (ManagementException ex4)
            {
                ex = ex4;
            }
            catch (OutOfMemoryException ex5)
            {
                ex = ex5;
            }
            if (ex != null)
            {
                AmTrace.Error("GetBootTimeWithWmi: WMI could not query the boot time on server {0}: {1}", new object[]
                {
                    machineName,
                    ex
                });
                ReplayEventLogConstants.Tuple_GetBootTimeWithWmiFailure.LogEvent(string.Empty, new object[]
                {
                    machineName,
                    ex.Message
                });
            }
            return(dateTime);
        }