public List<object> enumItem(bool recursion = false) { List<object> list = new List<object>(); foreach (DirectoryEntry de in de_.Children) { ADItem item = new ADItem(de); if (recursion) { if (item.type() == ADType.OU) { Dictionary<string, object> dic = new Dictionary<string, object>(); dic.Add(item.name(), item.enumItem(recursion)); list.Add(dic); } else list.Add(item.name()); } else list.Add(item.name()); } return list; }
public bool deleteSelf() { if (type() == ADType.OU) { foreach (DirectoryEntry de in de_.Children) { ADItem item = new ADItem(de); if (!item.deleteSelf()) return false; } } try { DirectoryEntry p = de_.Parent; p.Children.Remove(de_); p.CommitChanges(); } catch (Exception) { return false; } return true; }