private static TreeObject GetTreeObject(this DirectoryEntry Entry) { var tree = new TreeObject(); tree.label = Entry.GetProperty("name").Trim(); System.Console.WriteLine(tree.label); if (string.IsNullOrEmpty(tree.label) || IgnoresList.Contains(tree.label) || "内部用户" == tree.label || "特殊帐号".Trim() == tree.label) { return(null); } var description = Entry.GetProperty("description"); if (!string.IsNullOrEmpty(description)) { tree.label += "--" + description; } foreach (DirectoryEntry item in Entry.Children) { var temp = item.GetTreeObject(); if (temp != null) { tree.children.Add(temp); } } return(tree); }
public static Group GetTree(this DirectoryEntry Entry) { var name = Entry.GetProperty("name"); if (string.IsNullOrEmpty(name) || IgnoresList.Contains(name)) { return(null); } DateTime time; var group = new Group { Name = name, Descriptions = Entry.GetProperty("description"), CreateTime = DateTime.TryParse(Entry.GetProperty("whenCreated"), out time) ? time : time }; foreach (DirectoryEntry item in Entry.Children) { var temp = item.GetTree(); if (temp != null) { group.Children.Add(temp); } } return(group); }
private static Group GetTree(DirectoryEntry Entry) { var group = new Group(); var name = GetProperty(Entry, "name"); if (string.IsNullOrEmpty(name) || IgnoresList.Contains(name)) { return(null); } group.Name = name; group.Descriptions = GetProperty(Entry, "description"); DateTime time; DateTime.TryParse(GetProperty(Entry, "whenCreated"), out time); group.CreateTime = time; foreach (DirectoryEntry item in Entry.Children) { var temp = GetTree(item); if (temp != null) { group.Children.Add(temp); } } return(group); }
private static TreeObject GetTreeObject(DirectoryEntry Entry) { var tree = new TreeObject(); tree.label = GetProperty(Entry, "name"); if (string.IsNullOrEmpty(tree.label) || IgnoresList.Contains(tree.label) || "内部用户" == tree.label) { return(null); } var description = GetProperty(Entry, "description"); if (!string.IsNullOrEmpty(description)) { tree.label += "--" + description; } foreach (DirectoryEntry item in Entry.Children) { var temp = GetTreeObject(item); if (temp != null) { tree.children.Add(temp); } } return(tree); }
private static bool IsIgnore(string DistinguishedName) { var str = DistinguishedName.Split(','); for (var i = 1; i < str.Count(); i++) { if (IgnoresList.Contains(str[i].Replace("OU=", "").Replace("CN=", ""))) { return(true); } } return(false); }