From cc655e915f71a3461321b3a799c9e0165c802f2b Mon Sep 17 00:00:00 2001 From: Dylan Bickerstaff Date: Mon, 2 Sep 2019 22:50:16 -0400 Subject: [PATCH] Finished 0.1.0.0. Testing will begin. --- SuperADD/Main.cs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/SuperADD/Main.cs b/SuperADD/Main.cs index 57f7531..353fa39 100644 --- a/SuperADD/Main.cs +++ b/SuperADD/Main.cs @@ -744,11 +744,13 @@ private void OUList_SelectedIndexChanged(object sender, EventArgs e) showMsg("OrganizationalUnits element is missing from SuperADD.xml", warnImg); return; } + XElement SecurityGroupsDNs = null; foreach (XElement elm in OUs.Elements("OrganizationalUnit")) { XElement Name = elm.Element("Name"); if (Name != null && Name.Value == (string)lv.SelectedItem ) { + SecurityGroupsDNs = elm.Element("SecurityGroupsDNs"); XElement DN = elm.Element("DistinguishedName"); if (DN == null) continue; currentlySelectedOU = DN.Value; @@ -767,6 +769,27 @@ private void OUList_SelectedIndexChanged(object sender, EventArgs e) if((lv == OUList && tabControl.SelectedTab == compNameTab) && !suppressFindNextName) { findNextComputerName(); + autoSelectSecurityGroups(SecurityGroupsDNs); + } + } + private void autoSelectSecurityGroups(XElement SecurityGroupsDNs) + { + SGList.ClearSelected(); + if (SecurityGroupsDNs == null) return; + foreach(XElement SGDNs in SecurityGroupsDNs.Elements("SecurityGroupDN")) + { + XElement SGs = Config.Current.Element("SecurityGroups"); + if (SGs == null) continue; + foreach(XElement SG in SGs.Elements("SecurityGroup")) + { + XElement Name = SG.Element("Name"); + XElement DN = SG.Element("DistinguishedName"); + if (Name == null || DN == null) continue; + if (DN.Value == SGDNs.Value) + { + SGList.SelectedItems.Add(Name.Value); + } + } } } private void saveNextBtn_Click(object sender, EventArgs e)