/// <summary>
 /// MailSlotMessageArrived method implmentation
 /// </summary>
 private static void MailSlotMessageArrived(MailSlotServer maislotserver, MailSlotMessage message)
 {
     if (message.Operation == (byte)NotificationsKind.ConfigurationReload)
     {
         ADFSManager.Config = null;
         ADFSManager.EnsureLocalConfiguration(null); // Force Reload Configuration
     }
     else if (message.Operation == (byte)NotificationsKind.ServiceStatusRunning)
     {
         ADFSManager.ServicesStatus = ServiceOperationStatus.OperationRunning;
         ADFSManager.OnServiceStatusChanged(ADFSManager.ServicesStatus, message.Text);
     }
     else if (message.Operation == (byte)NotificationsKind.ServiceStatusStopped)
     {
         ADFSManager.ServicesStatus = ServiceOperationStatus.OperationStopped;
         ADFSManager.OnServiceStatusChanged(ADFSManager.ServicesStatus, message.Text);
     }
     else if (message.Operation == (byte)NotificationsKind.ServiceStatusPending)
     {
         ADFSManager.ServicesStatus = ServiceOperationStatus.OperationPending;
         ADFSManager.OnServiceStatusChanged(ADFSManager.ServicesStatus, message.Text);
     }
     else if (message.Operation == (byte)NotificationsKind.ServiceStatusInError)
     {
         ADFSManager.ServicesStatus = ServiceOperationStatus.OperationInError;
         ADFSManager.OnServiceStatusChanged(ADFSManager.ServicesStatus, message.Text);
     }
 }
        private bool IsLocalMessage(MailSlotMessage message)
        {
            string local  = Dns.GetHostName().ToUpper();
            string remote = message.MachineName.ToUpper();

            return(local.StartsWith(remote));
        }
 /// <summary>
 /// MailSlotMessageArrived method implmentation
 /// </summary>
 private static void MailSlotMessageArrived(MailSlotServer maislotserver, MailSlotMessage message)
 {
     if (message.Operation == 0xAA)
     {
         ADFSManager.Config = null;
         ADFSManager.EnsureLocalConfiguration(null); // Force Reload Configuration
         MailslotServer.AllowedMachines.Clear();
         foreach (ADFSServerHost svr in Config.Hosts.ADFSFarm.Servers)
         {
             MailslotServer.AllowedMachines.Add(svr.MachineName);
         }
     }
     else if (message.Operation == 0x10)
     {
         ADFSManager.ServicesStatus = ServiceOperationStatus.OperationRunning;
         ADFSManager.OnServiceStatusChanged(ADFSManager.ServicesStatus, message.Text);
     }
     else if (message.Operation == 0x11)
     {
         ADFSManager.ServicesStatus = ServiceOperationStatus.OperationStopped;
         ADFSManager.OnServiceStatusChanged(ADFSManager.ServicesStatus, message.Text);
     }
     else if (message.Operation == 0x12)
     {
         ADFSManager.ServicesStatus = ServiceOperationStatus.OperationPending;
         ADFSManager.OnServiceStatusChanged(ADFSManager.ServicesStatus, message.Text);
     }
     else if (message.Operation == 0x19)
     {
         ADFSManager.ServicesStatus = ServiceOperationStatus.OperationInError;
         ADFSManager.OnServiceStatusChanged(ADFSManager.ServicesStatus, message.Text);
     }
 }
Пример #4
0
 /// <summary>
 /// MFAMailSlotMessageArrived implementation
 /// </summary>
 private void SyncMailSlotMessages(MailSlotServer maislotserver, MailSlotMessage message)
 {
     if (message.Operation == (byte)NotificationsKind.ConfigurationReload) // Configuration Reload
     {
         DoOnSendConfiguration();
     }
     else if (message.Operation == (byte)NotificationsKind.ServiceServerInformation)
     {
         DoOnRequestServerConfiguration(message.Text);
     }
 }
        /// <summary>
        /// MailSlotMessageArrived implementation
        /// </summary>
        private void MailSlotMessageArrived(MailSlotServer maislotserver, MailSlotMessage message)
        {
            if (message.ApplicationName == "CP1")
            {
                switch (message.Operation)
                {
                case 0x10:
                    if (IsLocalMessage(message))
                    {
                        this.EventLog.WriteEntry(string.Format("Server Information REQUEST To {0}", message.Text), EventLogEntryType.SuccessAudit, 10000);
                        using (MailSlotClient mailslot = new MailSlotClient("CP1"))
                        {
                            mailslot.Text = Dns.GetHostEntry(message.Text).HostName.ToLower();
                            mailslot.SendNotification(0x11);
                        }
                    }
                    break;

                case 0x11:
                    if (!IsLocalMessage(message))
                    {
                        string localname = Dns.GetHostEntry("localhost").HostName.ToLower();
                        if (localname.ToLower().Equals(message.Text.ToLower()))
                        {
                            this.EventLog.WriteEntry(string.Format("Server Information RECEIVED for {0}", message.Text), EventLogEntryType.SuccessAudit, 10000);
                            using (MailSlotClient mailslot = new MailSlotClient("CP1"))
                            {
                                FarmUtilities reg = new FarmUtilities();
                                mailslot.Text = reg.InitServerNodeConfiguration();
                                mailslot.SendNotification(0x12);
                            }
                        }
                    }
                    break;

                case 0x12:
                    if (!IsLocalMessage(message))
                    {
                        FarmUtilities  reg  = new FarmUtilities();
                        ADFSServerHost host = reg.UnPackServerNodeConfiguration(message.Text);

                        ManagementService.EnsureService();
                        int i = ManagementService.ADFSManager.ADFSFarm.Servers.FindIndex(c => c.FQDN.ToLower() == host.FQDN.ToLower());
                        if (i < 0)
                        {
                            ManagementService.ADFSManager.ADFSFarm.Servers.Add(host);
                        }
                        else
                        {
                            ManagementService.ADFSManager.ADFSFarm.Servers[i] = host;
                        }

                        ManagementService.ADFSManager.SetDirty(true);
                        ManagementService.ADFSManager.WriteConfiguration(null);

                        this.EventLog.WriteEntry(string.Format("Server Information RESPONSE : {0}", message.Text), EventLogEntryType.SuccessAudit, 10000);
                    }
                    break;
                }
            }
        }