private void ADTree_AfterSelect(object sender, TreeViewEventArgs e) { if (!ADTree.Visible) { return; } if (e.Node.IsSelected) { string patha = e.Node.FullPath; ADNode adNode = AD_TREE == null ? null : (ADNode)AD_TREE.node2item[e.Node]; if (adNode != null) { AD_TREE.Open(adNode); e.Node.Expand(); searchRootBox.Text = adNode.de.Path; groupsBox.Items.Clear(); groupsLabel.Visible = false; groupName2Ldap.Clear(); membersBox.Items.Clear(); searchScopeBox.Checked = false; searchButton.PerformClick(); } } }
bool ADRefresh(Tree <ADNode> tree, TreeNode node, ADNode item, bool expand) { bool ret = true; if (item.depth < (expand ? tree.depth2 : tree.depth)) { List <DirectoryEntry> lde2 = new List <DirectoryEntry>(); DirectoryEntries children = null; children = item.de.Children; if (children != null) { foreach (DirectoryEntry de2_ in children) { lde2.Add(de2_); } } DirectoryEntry[] ade2 = new DirectoryEntry[lde2.Count]; lde2.CopyTo(ade2, 0); ade2.AsParallel().WithDegreeOfParallelism(expand ? 1 : 8).ForAll(de2 => { try { ADNode item2 = new ADNode(null, tree, de2, item.depth + 1); if (!item2.invalid) { TreeNode node2 = new TreeNode(item2.Name, 0, 1); item2.node = node2; if (item2.isDomain || (item2.isSite && item2.siteonly.Length == 3) || (item2.isDpt && take(item2.dpt, tree.exclude)) ) { tree.item2node[tree.node2item[node2] = item2] = node2; if (tree.shown()) { tree.GUI.set(tree.count, "" + tree.node2item.Count); } if (tree.shown()) { tree.GUI.add(node, node2); } //Console.WriteLine(level + "+OU=" + item.Name + " (" + item2.de.Path + ")"); } if (!expand && !ADRefresh(tree, node2, item2, expand)) { ret = false; } } } catch (Exception e) { Console.WriteLine("AD Error: " + de2.Name + ": " + e.ToString()); ret = false; } }); item.uptodate = true; } return(ret); }
/** * @return значение узла или null если такой не найден */ public BaseNode get(string id) { ADNode node = nodes.Where(x => x.getValue().getId().Equals(id)).FirstOrDefault(); if (node == default) { return(null); } return(node.getValue() != null?node.getValue() : null); }
/** * Найти элементы для связи * @param cur текущий элемент, кот надо связать * @param curNode */ private void findNext(DiagramElement cur, ADNode curNode) { // для всех выходный переходов находим таргеты и добавляем ссылки в текущий элемент на таргеты for (int i = 0; i < cur.outSize(); i++) { ControlFlow flow = (ControlFlow)get(cur.getOutId(i)); ADNode target = getNode(flow.getTarget()); curNode.next.Add(target); // прямая связь target.prev.Add(curNode); // обратная связь } }
public ADNode getNodeByPetriIndex(int id) { ADNode node = nodes.Where(x => { if (x.getValue() is DiagramElement) { return(((DiagramElement)x.getValue()).petriId == id); } return(false); }).FirstOrDefault(); return(node == default ? null : node); }
static void Parse(DirectoryEntry de, ADNode node) { node.invalid = true; if (de.Name.ToUpper().StartsWith("OU=") || de.Name.ToUpper().StartsWith("DC=")) { string path = de.Path == null ? "" : de.Path; path = Regex.Replace(path, "^LDAP://[A-Z.]+/", "", RegexOptions.IgnoreCase); path = Regex.Replace(path, "(DC=[A-Z]+),.*$", "$1", RegexOptions.IgnoreCase); node.isDomain = path.ToUpper().StartsWith("DC="); node.isSite = path.Count(c => c == ',') == 1; node.isDpt = path.Count(c => c == ',') == 2; string[] path_ = Regex.Replace(path, "[A-Z]+=", "", RegexOptions.IgnoreCase).Split(new char[] { ',' }); if (node.isDomain) { node.domain = path_[0].ToUpper(); } else if (node.isSite) { node.site = path_[0]; node.domain = path_[1].ToUpper(); node.siteonly = Regex.Replace(node.site, "^" + node.domain + " +", "", RegexOptions.IgnoreCase); } else if (node.isDpt) { node.dpt = path_[0]; node.site = path_[1]; node.domain = path_[2].ToUpper(); node.siteonly = Regex.Replace(node.site, "^" + node.domain + " +", "", RegexOptions.IgnoreCase); if (node.siteonly.Length != 3) { //Console.WriteLine("AD: Invalid site name: " + node.siteonly + " (name must be exactly 3 letters long)"); return; } } else { Console.WriteLine("AD: Unsupported directory entry: " + path + " (only domain, site, dpt are supported)"); return; } node.de = de; node.Name = de.Name.Substring(3); if (node.isDomain) { node.Name = node.Name.ToUpper(); } node.invalid = false; } }
private void ADTree_AfterSelect(object sender, TreeViewEventArgs e) { if (!ADTree.Visible) { return; } if (e.Node.IsSelected) { SetItemsChecked(DomainsBox, false); SetItemsChecked(SitesBox, false); SetItemsChecked(DptsBox, false); string patha = e.Node.FullPath; ADNode adNode = AD_TREE == null ? null : (ADNode)AD_TREE.node2item[e.Node]; if (adNode != null) { AD_TREE.Open(adNode); e.Node.Expand(); if (adNode.isDomain) { SetItemChecked(DomainsBox, adNode.domain, true); } else if (adNode.isSite) { SetItemChecked(DomainsBox, adNode.domain, true); SetItemChecked(SitesBox, adNode.site, true); } else if (adNode.isDpt) { SetItemChecked(DomainsBox, adNode.domain, true); SetItemChecked(SitesBox, adNode.site, true); SetItemChecked(DptsBox, adNode.dpt, true); } e.Node.Expand(); } calcSelectedMachines(-1, 0, false); } }
bool ADOpen(Tree <ADNode> tree, ADNode item) { bool ret = item.uptodate || ADRefresh(tree, item.node, item, true); return(ret); }
public bool ADRefresh(Tree <ADNode> tree) { bool ret = true; if (tree.shown()) { tree.GUI.update(tree.tree, true); } if (tree.depth > 0 && tree.depth2 >= tree.depth) { try { DomainCollection dc = Forest.GetCurrentForest().Domains; Domain[] domains = new Domain[dc.Count]; dc.CopyTo(domains, 0); domains.ToArray().AsParallel().ForAll(domain => { try { ADNode item = new ADNode(null, tree, domain.GetDirectoryEntry(), 1); TreeNode node = new TreeNode(item.Name, 2, 3); item.node = node; tree.item2node[tree.node2item[node] = item] = node; //Console.WriteLine(domain.GetDirectoryEntry().Name + " " + item.level + "/" + tree.depth2); if (tree.shown()) { tree.GUI.set(tree.count, "" + tree.node2item.Count); } if (tree.shown()) { tree.GUI.add(tree.tree, node); } if (tree.shown()) { tree.GUI.add(tree.list, item.Name); } if (!ADRefresh(tree, node, item, false)) { ret = false; } } catch (Exception e) { ret = false; Console.WriteLine("AD Error: Domain " + domain + ": " + e.ToString()); } }); } catch (Exception e) { Console.WriteLine("AD Error: " + e.ToString()); ret = false; } } if (tree.shown()) { tree.GUI.sort(tree.tree); } if (tree.shown()) { foreach (TreeNode node in tree.tree.Nodes) { tree.GUI.expand(node, false); } } if (tree.shown()) { tree.GUI.update(tree.tree, false); } return(ret); }
public ADNode(ADNode old) { value = old.value; next = old.next; prev = old.prev; }