/// <summary> /// UpgradeServersConfig method implementation (Client) /// </summary> private void UpgradeServersConfig(NamedPipeRegistryRecord reg) { NamedPipeRegistryRecord rec = FarmUtilities.InitServerNodeConfiguration(reg); MFAConfig cfg = CFGUtilities.ReadConfiguration(null); ADFSServerHost svr = null; if (cfg.Hosts.ADFSFarm.Servers.Exists(s => s.FQDN.ToLower().Equals(rec.FQDN.ToLower()))) { svr = cfg.Hosts.ADFSFarm.Servers.Find(s => s.FQDN.ToLower().Equals(rec.FQDN.ToLower())); cfg.Hosts.ADFSFarm.Servers.Remove(svr); } svr = new ADFSServerHost(); svr.FQDN = rec.FQDN; svr.CurrentVersion = rec.CurrentVersion; svr.CurrentBuild = rec.CurrentBuild; svr.CurrentMajorVersionNumber = rec.CurrentMajorVersionNumber; svr.CurrentMinorVersionNumber = rec.CurrentMinorVersionNumber; svr.InstallationType = rec.InstallationType; svr.ProductName = rec.ProductName; svr.NodeType = rec.NodeType; svr.BehaviorLevel = rec.BehaviorLevel; svr.HeartbeatTmeStamp = rec.HeartbeatTimestamp; cfg.Hosts.ADFSFarm.Servers.Add(svr); CFGUtilities.WriteConfiguration(null, cfg); using (MailSlotClient mailslot = new MailSlotClient()) { mailslot.Text = Environment.MachineName; mailslot.SendNotification(NotificationsKind.ConfigurationReload); } }
/// <summary> /// DoOnReceiveServerConfiguration method implementation (Server) /// </summary> private NamedPipeRegistryRecord DoOnReceiveServerConfiguration(string requestor) { RegistryVersion reg = new RegistryVersion(); NamedPipeRegistryRecord rec = default(NamedPipeRegistryRecord); rec.FQDN = Dns.GetHostEntry("LocalHost").HostName; rec.CurrentVersion = reg.CurrentVersion; rec.CurrentBuild = reg.CurrentBuild; rec.CurrentMajorVersionNumber = reg.CurrentMajorVersionNumber; rec.CurrentMinorVersionNumber = reg.CurrentMinorVersionNumber; rec.InstallationType = reg.InstallationType; rec.ProductName = reg.ProductName; rec.IsWindows2012R2 = reg.IsWindows2012R2; rec.IsWindows2016 = reg.IsWindows2016; rec.IsWindows2019 = reg.IsWindows2019; rec.NodeType = FarmUtilities.InitServerNodeType(); return(rec); }
/// <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; } } }