Example #1
0
        public static void UnregisterComponent(IDiagnosable diagnosable)
        {
            if (diagnosable == null)
            {
                throw new ArgumentNullException("diagnosable");
            }
            string diagnosticComponentName = diagnosable.GetDiagnosticComponentName();

            if (string.IsNullOrEmpty(diagnosticComponentName))
            {
                throw new ArgumentNullException("diagnosable.GetDiagnosticComponentName()");
            }
            lock (ProcessAccessManager.RpcServerLockObject)
            {
                ProcessAccessManager.diagnosableComponents.Remove(diagnosticComponentName);
                if (ProcessAccessManager.diagnosableComponents.Count == 0 && ProcessAccessManager.RpcServer != null)
                {
                    RpcServerBase.StopServer(ProcessAccessRpcServer.RpcIntfHandle);
                    ProcessAccessManager.RpcServer = null;
                }
            }
            IDiagnosableExtraData diagnosableExtraData = diagnosable as IDiagnosableExtraData;

            if (diagnosableExtraData != null)
            {
                diagnosableExtraData.OnStop();
            }
        }
Example #2
0
 internal static void Start()
 {
     ServerFqdnCache.InitializeCache();
     if (RfriServer.instance == null)
     {
         bool flag = false;
         try
         {
             RfriServer.instance = (RfriServer)RpcServerBase.RegisterAutoListenInterfaceSupportingAnonymous(typeof(RfriServer), RpcServerBase.DefaultMaxRpcCalls, "Microsoft Exchange RFR Interface", true);
             flag = true;
         }
         catch (RpcException ex)
         {
             RfriServer.ReferralTracer.TraceError <string>(0L, "Error registering the RFR RPC interface: {0}", ex.Message);
             RfriServer.eventLog.LogEvent(AddressBookEventLogConstants.Tuple_RpcRegisterInterfaceFailure, string.Empty, new object[]
             {
                 "RFR",
                 ServiceHelper.FormatWin32ErrorString(ex.ErrorCode)
             });
         }
         finally
         {
             if (!flag)
             {
                 RfriServer.rfriAsyncDispatch = null;
                 RfriServer.Stop();
                 RfriServer.instance = null;
             }
         }
     }
 }
 // Token: 0x06000028 RID: 40 RVA: 0x00002A38 File Offset: 0x00000C38
 private static bool TryRegisterRpcServer(ObjectSecurity rpcSecurityDescriptor, out ThrottlingRpcServerImpl serverInstance)
 {
     ThrottlingService.StartStopBreadcrumbs.Drop("Trying to register RPC server", new object[0]);
     ThrottlingService.Tracer.TraceDebug(0L, "Trying to register RPC server");
     serverInstance = null;
     try
     {
         serverInstance = (ThrottlingRpcServerImpl)RpcServerBase.RegisterServer(typeof(ThrottlingRpcServerImpl), rpcSecurityDescriptor, 1, false, ThrottlingRpcServerImpl.GetThreadPoolSize());
     }
     catch (RpcException ex)
     {
         ThrottlingService.StartStopBreadcrumbs.Drop("Failed to register RPC server: {0}", new object[]
         {
             ex
         });
         ThrottlingService.Tracer.TraceError <RpcException>(0L, "Failed to register RPC server: {0}", ex);
         ThrottlingService.EventLogger.LogEvent(ThrottlingServiceEventLogConstants.Tuple_RegisterRpcServerFailure, null, new object[]
         {
             ex
         });
         return(false);
     }
     ThrottlingService.StartStopBreadcrumbs.Drop("Successfully registered RPC server", new object[0]);
     ThrottlingService.Tracer.TraceDebug(0L, "Successfully registered RPC server");
     return(true);
 }
Example #4
0
        public static bool Start(TimeSpan enqueueRequestTimeout, out Exception e)
        {
            RpcServerWrapper.enqueueRequestTimeout = enqueueRequestTimeout;
            e = null;
            if (RpcServerWrapper.Registered == 1)
            {
                return(true);
            }
            SecurityIdentifier   securityIdentifier = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null);
            FileSystemAccessRule accessRule         = new FileSystemAccessRule(securityIdentifier, FileSystemRights.Read, AccessControlType.Allow);
            FileSecurity         fileSecurity       = new FileSecurity();

            fileSecurity.SetOwner(securityIdentifier);
            fileSecurity.SetAccessRule(accessRule);
            bool result;

            try
            {
                RpcServerBase.RegisterServer(typeof(RpcServerWrapper), fileSecurity, 131209);
                Interlocked.CompareExchange(ref RpcServerWrapper.Registered, 1, 0);
                result = true;
            }
            catch (RpcException ex)
            {
                e = ex;
                Interlocked.CompareExchange(ref RpcServerWrapper.Registered, 0, 1);
                result = false;
            }
            return(result);
        }
Example #5
0
 internal static void Start()
 {
     if (NspiServer.instance == null)
     {
         bool flag = false;
         try
         {
             NspiServer.instance = (NspiServer)RpcServerBase.RegisterAutoListenInterfaceSupportingAnonymous(typeof(NspiServer), RpcServerBase.DefaultMaxRpcCalls, "Microsoft Exchange NSPI Interface", false);
             NspiServer.instance.StartRundownQueue();
             flag = true;
         }
         catch (RpcException ex)
         {
             NspiServer.NspiTracer.TraceError <string>(0L, "Error registering the NSPI RPC interface: {0}", ex.Message);
             NspiServer.eventLog.LogEvent(AddressBookEventLogConstants.Tuple_RpcRegisterInterfaceFailure, string.Empty, new object[]
             {
                 "NSPI",
                 ServiceHelper.FormatWin32ErrorString(ex.ErrorCode)
             });
         }
         finally
         {
             if (!flag)
             {
                 NspiServer.nspiAsyncDispatch = null;
                 NspiServer.Stop();
                 NspiServer.instance = null;
             }
         }
     }
 }
 public static void Stop()
 {
     if (ExchangeCertificateServer.server != null)
     {
         RpcServerBase.StopServer(ExchangeCertificateRpcServer.RpcIntfHandle);
         ExchangeCertificateServer.server = null;
     }
 }
Example #7
0
        public static void Stop()
        {
            int num = Interlocked.CompareExchange(ref RpcServerWrapper.Registered, 0, 1);

            if (num == 1)
            {
                RpcServerBase.StopServer(UnifiedPolicyNotificationRpcServer.RpcIntfHandle);
            }
        }
Example #8
0
 internal static void Stop()
 {
     if (NspiServer.instance != null)
     {
         RpcServerBase.UnregisterInterface(NspiAsyncRpcServer.RpcIntfHandle);
         NspiServer.instance.StopRundownQueue();
         NspiServer.instance = null;
     }
 }
Example #9
0
        public static void Stop()
        {
            int num = Interlocked.CompareExchange(ref RpcServerWrapper.Registered, 0, 1);

            if (num == 1)
            {
                RpcServerBase.StopServer(JobQueueRpcServer.RpcIntfHandle);
            }
        }
Example #10
0
 internal static void Stop()
 {
     if (RfriServer.instance != null)
     {
         RpcServerBase.UnregisterInterface(RfriAsyncRpcServer.RpcIntfHandle, true);
         RfriServer.instance = null;
     }
     ServerFqdnCache.TerminateCache();
 }
 // Token: 0x06000023 RID: 35 RVA: 0x00002750 File Offset: 0x00000950
 public void Stop()
 {
     ThrottlingService.StartStopBreadcrumbs.Drop("Stopping RPC Server", new object[0]);
     RpcServerBase.StopServer(ThrottlingRpcServer.RpcIntfHandle);
     ThrottlingService.StartStopBreadcrumbs.Drop("RPC Server stopped", new object[0]);
     this.userSubmissionTokens.Stop();
     this.userSubmissionTokens = null;
     this.mailboxRuleSubmissionTokens.Stop();
     this.mailboxRuleSubmissionTokens = null;
 }
        internal static void StartServer()
        {
            SecurityIdentifier   securityIdentifier = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null);
            FileSystemAccessRule accessRule         = new FileSystemAccessRule(securityIdentifier, FileSystemRights.ReadData, AccessControlType.Allow);
            FileSecurity         fileSecurity       = new FileSecurity();

            fileSecurity.SetOwner(securityIdentifier);
            fileSecurity.SetAccessRule(accessRule);
            MailboxSearchServer.server = (MailboxSearchServer)RpcServerBase.RegisterServer(typeof(MailboxSearchServer), fileSecurity, 1);
            MailboxSearchServer.server.InternalStart();
        }
Example #13
0
 // Token: 0x0600045B RID: 1115 RVA: 0x000170CC File Offset: 0x000152CC
 public static void Stop()
 {
     lock (AmRpcServer.m_locker)
     {
         AmTrace.Debug("Stopping Active Manager Rpc", new object[0]);
         if (AmRpcServer.m_rpcServer != null)
         {
             RpcServerBase.StopServer(AmRpcServerBase.RpcIntfHandle);
             AmRpcServer.m_rpcServer         = null;
             AmRpcServer.m_fRpcServerStarted = false;
         }
     }
 }
Example #14
0
        // Token: 0x060000CA RID: 202 RVA: 0x00005420 File Offset: 0x00003620
        public static void StartServer(SecurityIdentifier exchangeServersSid)
        {
            SecurityIdentifier   securityIdentifier = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null);
            FileSystemAccessRule accessRule         = new FileSystemAccessRule(securityIdentifier, FileSystemRights.ReadData, AccessControlType.Allow);
            SecurityIdentifier   identity           = new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null);
            FileSystemAccessRule rule         = new FileSystemAccessRule(identity, FileSystemRights.ReadData, AccessControlType.Allow);
            FileSystemAccessRule rule2        = new FileSystemAccessRule(exchangeServersSid, FileSystemRights.ReadData, AccessControlType.Allow);
            FileSecurity         fileSecurity = new FileSecurity();

            fileSecurity.SetOwner(securityIdentifier);
            fileSecurity.SetAccessRule(accessRule);
            fileSecurity.AddAccessRule(rule);
            fileSecurity.AddAccessRule(rule2);
            RpcServerBase.RegisterServer(typeof(AssistantsRpcServer), fileSecurity, 1);
        }
Example #15
0
        // Token: 0x06000117 RID: 279 RVA: 0x00008600 File Offset: 0x00006800
        protected override void OnStopInternal()
        {
            ExTraceGlobals.ServiceTracer.TraceDebug((long)this.GetHashCode(), "MsExchangeLogSearch service is stopping");
            bool flag = false;

            if (Monitor.TryEnter(LogSearchService.logSearchService, TimeSpan.FromSeconds(10.0)))
            {
                try
                {
                    this.localServer.Unload();
                    if (LogSearchService.configReloadTimer != null)
                    {
                        LogSearchService.configReloadTimer.Dispose(false);
                    }
                    if (this.sessionManager != null)
                    {
                        this.sessionManager.Stop();
                    }
                    if (LogSearchRpcServer.RpcIntfHandle != IntPtr.Zero)
                    {
                        RpcServerBase.StopServer(LogSearchRpcServer.RpcIntfHandle);
                    }
                    if (this.messageTrackingLog != null)
                    {
                        this.messageTrackingLog.Stop();
                    }
                    if (this.healthLog != null)
                    {
                        this.healthLog.Dispose();
                        this.healthLog = null;
                    }
                    EHALogSearchComponent.Stop();
                    LogSearchService.logger.LogEvent(MSExchangeTransportLogSearchEventLogConstants.Tuple_LogSearchServiceStopSuccess, null, new object[0]);
                    ExTraceGlobals.ServiceTracer.TraceDebug((long)this.GetHashCode(), "MsExchangeLogSearch service stopped successfully");
                    this.localServer = null;
                    flag             = true;
                }
                finally
                {
                    Monitor.Exit(LogSearchService.logSearchService);
                    if (!flag)
                    {
                        LogSearchService.logger.LogEvent(MSExchangeTransportLogSearchEventLogConstants.Tuple_LogSearchServiceStopFailure, null, new object[0]);
                        ExTraceGlobals.ServiceTracer.TraceError((long)this.GetHashCode(), "MsExchangeLogSearch services failure to stop");
                    }
                }
            }
        }
Example #16
0
        public void DiscoverRoutesOn([NotNull] RpcServerBase serverObject)
        {
            var type = serverObject.GetType();
            const BindingFlags allKinds = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;
            var methods = type.GetMethods(allKinds);

            foreach (var method in methods)
            {
                var handlerAttr = method.GetCustomAttribute <RpcMethodHandlerAttribute>();

                if (handlerAttr == null)
                {
                    continue;
                }

                var thiz = method.IsStatic ? null : serverObject;
                var del  = (RouteHandler)Delegate.CreateDelegate(typeof(RouteHandler), thiz, method);

                AddRoute(handlerAttr.MethodName, del);
            }
        }
        public static bool Start(out Exception e)
        {
            e = null;
            SecurityIdentifier   securityIdentifier = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null);
            FileSystemAccessRule accessRule         = new FileSystemAccessRule(securityIdentifier, FileSystemRights.Read, AccessControlType.Allow);
            FileSecurity         fileSecurity       = new FileSecurity();

            fileSecurity.SetOwner(securityIdentifier);
            fileSecurity.SetAccessRule(accessRule);
            bool result;

            try
            {
                ExchangeCertificateServer.server = (ExchangeCertificateServer)RpcServerBase.RegisterServer(typeof(ExchangeCertificateServer), fileSecurity, 1, false);
                result = true;
            }
            catch (RpcException ex)
            {
                e      = ex;
                result = false;
            }
            return(result);
        }
Example #18
0
        // Token: 0x0600045A RID: 1114 RVA: 0x00016E6C File Offset: 0x0001506C
        public static bool TryStart(ActiveManagerCore amInstance)
        {
            bool fRpcServerStarted;

            lock (AmRpcServer.m_locker)
            {
                if (!AmRpcServer.m_fRpcServerStarted)
                {
                    AmTrace.Debug("Starting Active Manager Rpc", new object[0]);
                    AmRpcServer.m_amInstance = amInstance;
                    try
                    {
                        FileSecurity activeManagerRpcSecurity = Microsoft.Exchange.Cluster.Replay.ObjectSecurity.ActiveManagerRpcSecurity;
                        if (activeManagerRpcSecurity != null)
                        {
                            AmRpcServer.m_rpcServer = (AmRpcServer)RpcServerBase.RegisterServer(typeof(AmRpcServer), activeManagerRpcSecurity, 1, false, (uint)RegistryParameters.MaximumRpcThreadCount);
                            if (AmRpcServer.m_rpcServer != null)
                            {
                                AmTrace.Debug("Active Manager Rpc server successfully started.", new object[0]);
                                AmRpcServer.m_fRpcServerStarted = true;
                            }
                        }
                        if (AmRpcServer.m_rpcServer == null)
                        {
                            AmTrace.Error("Active Manager Rpc server failed to start!", new object[0]);
                            ReplayEventLogConstants.Tuple_AmRpcServerFailedToStart.LogEvent(null, new object[0]);
                        }
                        goto IL_1BF;
                    }
                    catch (RpcException ex)
                    {
                        AmTrace.Error("RPC Error occurred while trying to register the Active Manager RPC Server. Exception: {0}", new object[]
                        {
                            ex.ToString()
                        });
                        ReplayEventLogConstants.Tuple_AmRpcServerFailedToRegister.LogEvent(null, new object[]
                        {
                            ex.Message
                        });
                        goto IL_1BF;
                    }
                    catch (ADTransientException ex2)
                    {
                        AmTrace.Error("Transient exception occurred while retrieving the ActiveManagerRpcSecurity object. Exception: {0}", new object[]
                        {
                            ex2.ToString()
                        });
                        ReplayEventLogConstants.Tuple_AmRpcServerFailedToFindExchangeServersUsg.LogEvent(null, new object[]
                        {
                            ex2.Message
                        });
                        goto IL_1BF;
                    }
                    catch (ADExternalException ex3)
                    {
                        AmTrace.Error("Start(): Permanent exception occurred while retrieving the ActiveManagerRpcSecurity object. Exception: {0}", new object[]
                        {
                            ex3.ToString()
                        });
                        ReplayEventLogConstants.Tuple_AmRpcServerFailedToFindExchangeServersUsg.LogEvent(null, new object[]
                        {
                            ex3.Message
                        });
                        goto IL_1BF;
                    }
                    catch (ADOperationException ex4)
                    {
                        AmTrace.Error("Start(): Permanent exception occurred while retrieving the ActiveManagerRpcSecurity object. Exception: {0}", new object[]
                        {
                            ex4.ToString()
                        });
                        ReplayEventLogConstants.Tuple_AmRpcServerFailedToFindExchangeServersUsg.LogEvent(null, new object[]
                        {
                            ex4.Message
                        });
                        goto IL_1BF;
                    }
                }
                AmTrace.Debug("Active Manager RPC server already started.", new object[0]);
IL_1BF:
                fRpcServerStarted = AmRpcServer.m_fRpcServerStarted;
            }
            return(fRpcServerStarted);
        }
 internal static void StopServer()
 {
     MailboxSearchServer.server.InternalShutdown();
     RpcServerBase.StopServer(MailboxSearchRpcServer.RpcIntfHandle);
     MailboxSearchServer.server = null;
 }
Example #20
0
        // Token: 0x0600011A RID: 282 RVA: 0x00008870 File Offset: 0x00006A70
        private void Initialize(Server server, ObjectSecurity adminSecurity)
        {
            ExTraceGlobals.ServiceTracer.TraceDebug((long)this.GetHashCode(), "MsExchangeLogSearch service is entering Initialize");
            bool flag = false;

            LogSearchService.LogSearchServiceStartState logSearchServiceStartState = LogSearchService.LogSearchServiceStartState.Init;
            try
            {
                this.sessionManager = new LogSessionManager();
                this.sessionManager.Start();
                logSearchServiceStartState = LogSearchService.LogSearchServiceStartState.SessionManagerStartup;
                if (server.IsHubTransportServer)
                {
                    EHALogSearchComponent.Start(server.Name);
                }
                if (LogSearchAppConfig.Instance.HealthMonitoringLog == null)
                {
                    ExTraceGlobals.ServiceTracer.TraceError((long)this.GetHashCode(), "Health monitoring log could not be initialized, service will be stopped");
                }
                else
                {
                    this.healthLog = new HealthMonitoringLog();
                    this.healthLog.Configure(LogSearchAppConfig.Instance.HealthMonitoringLog);
                    logSearchServiceStartState = LogSearchService.LogSearchServiceStartState.HealthMonitoringLogStartup;
                    this.ConfigureTransportSyncComponent(server);
                    logSearchServiceStartState = LogSearchService.LogSearchServiceStartState.SyncHealthLogStartup;
                    if (server.MessageTrackingLogPath != null && !string.IsNullOrEmpty(server.MessageTrackingLogPath.PathName))
                    {
                        this.messageTrackingLog = new Log(MessageTrackingSchema.MessageTrackingEvent, server.MessageTrackingLogPath.ToString(), "MSGTRK", server.Name, "LOG", LogSearchIndexingParameters.MessageTrackingIndexPercentageByPrefix);
                        this.messageTrackingLog.Config(server.MessageTrackingLogPath.ToString());
                        this.messageTrackingLog.Start();
                        this.sessionManager.RegisterLog("MSGTRK", this.messageTrackingLog);
                        logSearchServiceStartState = LogSearchService.LogSearchServiceStartState.MessageTrackingLogStartup;
                    }
                    else if (!server.IsClientAccessServer)
                    {
                        LogSearchService.logger.LogEvent(MSExchangeTransportLogSearchEventLogConstants.Tuple_LogSearchNullOrEmptyLogPath, null, new object[0]);
                        EventNotificationItem.Publish(ExchangeComponent.Transport.Name, "TransportLogSearch", null, "The Microsoft Exchange Transport Log Search service failed because the parameter that sets the location of the message tracking logs was set to an invalid value.", ResultSeverityLevel.Warning, false);
                    }
                    ActiveDirectoryRights accessMask = ActiveDirectoryRights.GenericRead;
                    bool flag2 = !server.IsHubTransportServer && !server.IsMailboxServer;
                    LogSearchService.logSearchServer = (LogSearchServer)RpcServerBase.RegisterServer(typeof(LogSearchServer), adminSecurity, accessMask, flag2);
                    ExTraceGlobals.ServiceTracer.TraceDebug <bool>((long)this.GetHashCode(), "RPC is registered. LocalRpcOnly = {0}", flag2);
                    LogSearchService.logSearchServer.SessionManager = this.sessionManager;
                    flag = true;
                }
            }
            finally
            {
                if (!flag)
                {
                    if (this.sessionManager != null)
                    {
                        this.sessionManager.Stop();
                        this.sessionManager = null;
                    }
                    if (this.messageTrackingLog != null)
                    {
                        this.messageTrackingLog.Stop();
                        this.messageTrackingLog = null;
                    }
                    if (this.healthLog != null)
                    {
                        this.healthLog.Dispose();
                        this.healthLog = null;
                    }
                    switch (logSearchServiceStartState)
                    {
                    case LogSearchService.LogSearchServiceStartState.Init:
                    {
                        string text = "MsExchangeLogSearch services Initialize failure because session manager startup failed";
                        ExTraceGlobals.ServiceTracer.TraceError((long)this.GetHashCode(), text);
                        LogSearchService.logger.LogEvent(MSExchangeTransportLogSearchEventLogConstants.Tuple_LogSearchServiceStartFailureInit, null, new object[0]);
                        EventNotificationItem.Publish(ExchangeComponent.Transport.Name, "TransportLogSearch", null, text, ResultSeverityLevel.Error, false);
                        break;
                    }

                    case LogSearchService.LogSearchServiceStartState.SessionManagerStartup:
                    {
                        string text = "MsExchangeLogSearch services Initialize failure because message tracking log failed";
                        ExTraceGlobals.ServiceTracer.TraceError((long)this.GetHashCode(), text);
                        LogSearchService.logger.LogEvent(MSExchangeTransportLogSearchEventLogConstants.Tuple_LogSearchServiceStartFailureSessionManager, null, new object[0]);
                        EventNotificationItem.Publish(ExchangeComponent.Transport.Name, "TransportLogSearch", null, text, ResultSeverityLevel.Error, false);
                        break;
                    }

                    case LogSearchService.LogSearchServiceStartState.MessageTrackingLogStartup:
                    {
                        string text = "MsExchangeLogSearch services Initialize failure because RPC server startup failed";
                        ExTraceGlobals.ServiceTracer.TraceError((long)this.GetHashCode(), text);
                        LogSearchService.logger.LogEvent(MSExchangeTransportLogSearchEventLogConstants.Tuple_LogSearchServiceStartFailureMTGLog, null, new object[0]);
                        EventNotificationItem.Publish(ExchangeComponent.Transport.Name, "TransportLogSearch", null, text, ResultSeverityLevel.Error, false);
                        break;
                    }
                    }
                }
            }
        }