Esempio n. 1
0
        private bool ServerHasMailboxRole(string serverName)
        {
            MiniServer miniServer = null;

            try
            {
                miniServer = this.m_adSession.FindMiniServerByFqdn(SharedHelper.GetFqdnNameFromNode(serverName), FileShareWitness.s_miniServerProperties);
            }
            catch (ADTransientException ex)
            {
                TaskLogger.Trace("Attempt to check mailbox role for server {0} failed. Specific error: {1}", new object[]
                {
                    serverName,
                    ex
                });
            }
            catch (ADExternalException ex2)
            {
                TaskLogger.Trace("Attempt to check mailbox role for server {0} failed. Specific error: {1}", new object[]
                {
                    serverName,
                    ex2
                });
            }
            catch (ADOperationException ex3)
            {
                TaskLogger.Trace("Attempt to check mailbox role for server {0} failed. Specific error: {1}", new object[]
                {
                    serverName,
                    ex3
                });
            }
            return(miniServer != null && miniServer.IsMailboxServer);
        }
        internal void SuspendDatabaseCopyIfNecessary(ReplayConfiguration config)
        {
            string text = string.Empty;

            text = config.TargetMachine;
            if (!this.m_fConfigOnly && !WmiWrapper.IsFileExisting(text, config.DestinationEdbPath))
            {
                string fileName = string.Empty;
                fileName = Path.Combine(config.DestinationLogPath, EseHelper.MakeLogfileName(config.LogFilePrefix, "." + config.LogExtension, 1L));
                if (!WmiWrapper.IsFileExisting(SharedHelper.GetFqdnNameFromNode(config.SourceMachine), fileName))
                {
                    try
                    {
                        this.WriteWarning(Strings.EnableDBCSuspendReplayNoDbComment(config.Name));
                        ReplayRpcClientWrapper.RequestSuspend(text, config.IdentityGuid, Strings.EnableDBCSuspendReplayNoDbComment(config.Name));
                        ReplayEventLogConstants.Tuple_DbSeedingRequired.LogEvent(null, new object[]
                        {
                            config.Name,
                            text
                        });
                    }
                    catch (TaskServerTransientException ex)
                    {
                        ExTraceGlobals.CmdletsTracer.TraceDebug <TaskServerTransientException>((long)this.GetHashCode(), "SeedDatabase: Caught exception in RPC: {0}", ex);
                        base.WriteError(new InvalidOperationException(Strings.SgcFailedToSuspendRpc(config.Name, ex.Message)), ErrorCategory.InvalidOperation, this.Identity);
                    }
                    catch (TaskServerException ex2)
                    {
                        ExTraceGlobals.CmdletsTracer.TraceDebug <TaskServerException>((long)this.GetHashCode(), "SeedDatabase: Caught exception in RPC: {0}", ex2);
                        if (!(ex2 is ReplayServiceSuspendWantedSetException))
                        {
                            if (ex2 is ReplayServiceSuspendRpcPartialSuccessCatalogFailedException)
                            {
                                base.WriteWarning(ex2.Message);
                            }
                            else
                            {
                                base.WriteError(new InvalidOperationException(Strings.SgcFailedToSuspendRpc(config.Name, ex2.Message)), ErrorCategory.InvalidOperation, this.Identity);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        private static bool IsMachineNameLocal(string machineName, bool usableRemotely)
        {
            if (string.IsNullOrEmpty(machineName))
            {
                return(false);
            }
            string machineName2 = Environment.MachineName;

            if (Cluster.StringIEquals(machineName, machineName2))
            {
                return(true);
            }
            string fqdnNameFromNode = SharedHelper.GetFqdnNameFromNode(machineName2);

            if (Cluster.StringIEquals(machineName, fqdnNameFromNode))
            {
                return(true);
            }
            if (Cluster.StringIEquals(machineName, "localhost"))
            {
                return(!usableRemotely);
            }
            IPHostEntry hostEntry;

            try
            {
                hostEntry = Dns.GetHostEntry(machineName);
            }
            catch (SocketException arg)
            {
                ExTraceGlobals.SeederServerTracer.TraceDebug <string, bool, SocketException>(0L, "SeedHelper: IsMachineNameLocal( {0}, {1} ) threw a SocketException: {2}.", machineName, usableRemotely, arg);
                return(false);
            }
            IPHostEntry hostEntry2 = Dns.GetHostEntry("localhost");

            foreach (IPAddress ipaddress in hostEntry2.AddressList)
            {
                if (Cluster.StringIEquals(ipaddress.ToString(), machineName))
                {
                    return(!usableRemotely);
                }
                foreach (IPAddress obj in hostEntry.AddressList)
                {
                    if (ipaddress.Equals(obj))
                    {
                        return(!usableRemotely);
                    }
                }
            }
            hostEntry2 = Dns.GetHostEntry("..localmachine");
            foreach (IPAddress ipaddress2 in hostEntry2.AddressList)
            {
                if (Cluster.StringIEquals(ipaddress2.ToString(), machineName))
                {
                    return(true);
                }
                foreach (IPAddress obj2 in hostEntry.AddressList)
                {
                    if (ipaddress2.Equals(obj2))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }