internal static void DoAutoRunProfileDiscovery(MAControllerConfiguration config, ManagementAgent ma) { foreach (PartitionConfiguration p in config.Partitions) { MAConfigDiscovery.DoAutoRunProfileDiscovery(p, ma); } }
private void AddMissingManagementAgents() { foreach (ManagementAgent ma in ManagementAgent.GetManagementAgents()) { bool found = false; foreach (MAControllerConfiguration config in this.ManagementAgents) { if (config.ManagementAgentID == ma.ID) { found = true; break; } } if (!found) { MAControllerConfiguration p = new MAControllerConfiguration(ma.Name, ma.ID); p.Disabled = true; p.ResolvePartitions(ma); MAConfigDiscovery.AddDefaultTriggers(p, ma); this.ManagementAgents.Add(p); } } }
internal static void AddDefaultTriggers(MAControllerConfiguration config, ManagementAgent ma) { switch (ma.Category) { case "FIM": FimServicePendingImportTrigger t1 = new FimServicePendingImportTrigger(ma); config.Triggers.Add(t1); break; case "ADAM": case "AD": ActiveDirectoryChangeTrigger t2 = new ActiveDirectoryChangeTrigger(ma); config.Triggers.Add(t2); break; } }
public void Start(Guid managementAgentID) { MAControllerConfiguration c = Program.ActiveConfig.ManagementAgents.GetItemOrDefault(managementAgentID); if (c == null) { throw new InvalidOperationException($"There was no active configuration found for the management agent {managementAgentID}"); } MAController e = this.GetContorllerOrThrow(managementAgentID); lock (e) { logger.Trace($"Starting {e.ManagementAgentName}"); e.Start(c); } }
public MAControllerScript(MAControllerConfiguration config) { this.ScriptPath = config.MAControllerPath; this.config = config; if (string.IsNullOrEmpty(this.ScriptPath)) { return; } if (!File.Exists(this.ScriptPath)) { logger.Warn($"{config.ManagementAgentName}: Controller script not found: {this.ScriptPath}"); return; } this.InitializePowerShellSession(); }
private bool DoSchemaUpdatev1(string file) { logger.Info("Configuration file upgrade in progress"); XmlDocument d = new XmlDocument(); var mgr = new XmlNamespaceManager(d.NameTable); mgr.AddNamespace("a", "http://schemas.datacontract.org/2004/07/Lithnet.Miiserver.AutoSync"); d.Load(file); foreach (XmlNode node in d.SelectNodes("/a:lithnet-autosync/a:management-agents/a:management-agent", mgr)) { string maName = node.SelectSingleNode("a:name", mgr)?.InnerText; string maidstr = node.SelectSingleNode("a:id", mgr)?.InnerText; Guid maID = maidstr == null ? Guid.Empty : new Guid(maidstr); Guid?id = Global.FindManagementAgent(maName, maID); if (id == null) { continue; } ManagementAgent ma = ManagementAgent.GetManagementAgent(id.Value); logger.Info($"Processing management agent controller {ma.Name}"); MAControllerConfiguration c = this.ManagementAgents.GetItemOrDefault(id.Value); foreach (PartitionConfiguration p in c.Partitions.ActiveConfigurations) { p.AutoImportEnabled = node.SelectSingleNode("a:auto-import-scheduling", mgr)?.InnerText == "enabled"; p.AutoImportIntervalMinutes = int.Parse(node.SelectSingleNode("a:auto-import-interval", mgr)?.InnerText ?? "0"); } string rpName = node.SelectSingleNode("a:run-profile-confirming-import", mgr)?.InnerText; Guid? pid = this.GetPartitionFromRunProfile(rpName, ma); if (pid != null) { PartitionConfiguration partition = c.Partitions.GetItemOrNull(pid.Value); if (partition != null) { partition.ConfirmingImportRunProfileName = rpName; logger.Trace($"Migrating run profile {nameof(partition.ConfirmingImportRunProfileName)}-{partition.ConfirmingImportRunProfileName} to partition {partition.Name}"); } } rpName = node.SelectSingleNode("a:run-profile-delta-import", mgr)?.InnerText; pid = this.GetPartitionFromRunProfile(rpName, ma); if (pid != null) { PartitionConfiguration partition = c.Partitions.GetItemOrNull(pid.Value); if (partition != null) { partition.DeltaImportRunProfileName = rpName; logger.Trace($"Migrating run profile {nameof(partition.DeltaImportRunProfileName)}-{partition.DeltaImportRunProfileName} to partition {partition.Name}"); } } rpName = node.SelectSingleNode("a:run-profile-delta-sync", mgr)?.InnerText; pid = this.GetPartitionFromRunProfile(rpName, ma); if (pid != null) { PartitionConfiguration partition = c.Partitions.GetItemOrNull(pid.Value); if (partition != null) { partition.DeltaSyncRunProfileName = rpName; logger.Trace($"Migrating run profile {nameof(partition.DeltaSyncRunProfileName)}-{partition.DeltaSyncRunProfileName} to partition {partition.Name}"); } } rpName = node.SelectSingleNode("a:run-profile-export", mgr)?.InnerText; pid = this.GetPartitionFromRunProfile(rpName, ma); if (pid != null) { PartitionConfiguration partition = c.Partitions.GetItemOrNull(pid.Value); if (partition != null) { partition.ExportRunProfileName = rpName; logger.Trace($"Migrating run profile {nameof(partition.ExportRunProfileName)}-{partition.ExportRunProfileName} to partition {partition.Name}"); } } rpName = node.SelectSingleNode("a:run-profile-full-import", mgr)?.InnerText; pid = this.GetPartitionFromRunProfile(rpName, ma); if (pid != null) { PartitionConfiguration partition = c.Partitions.GetItemOrNull(pid.Value); if (partition != null) { partition.FullImportRunProfileName = rpName; logger.Trace($"Migrating run profile {nameof(partition.FullImportRunProfileName)}-{partition.FullImportRunProfileName} to partition {partition.Name}"); } } rpName = node.SelectSingleNode("a:run-profile-full-sync", mgr)?.InnerText; pid = this.GetPartitionFromRunProfile(rpName, ma); if (pid != null) { PartitionConfiguration partition = c.Partitions.GetItemOrNull(pid.Value); if (partition != null) { partition.FullSyncRunProfileName = rpName; logger.Trace($"Migrating run profile {nameof(partition.FullSyncRunProfileName)}-{partition.FullSyncRunProfileName} to partition {partition.Name}"); } } rpName = node.SelectSingleNode("a:run-profile-scheduled-import", mgr)?.InnerText; pid = this.GetPartitionFromRunProfile(rpName, ma); if (pid != null) { PartitionConfiguration partition = c.Partitions.GetItemOrNull(pid.Value); if (partition != null) { partition.ScheduledImportRunProfileName = rpName; logger.Trace($"Migrating run profile {nameof(partition.ScheduledImportRunProfileName)}-{partition.ScheduledImportRunProfileName} to partition {partition.Name}"); } } } this.SchemaVersion = 1; return(true); }