【发布时间】:2017-09-05 21:22:35
【问题描述】:
我有一个显示我们 ActiveDirectory 的所有组成员的 DataGridView。双击组时,我想在树视图中显示该组的所有成员和子成员(包括用户)。我已经做了几次尝试,但我的问题是该过程需要运行,直到所有成员和子成员都已添加到树视图中,我无法做到这一点。 我需要为此使用某种模式吗? 从这里开始,我的代码应该是怎样的?
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
GroupPrincipal gp = GroupPrincipal.FindByIdentity(ctx, name);
var nodes = new List<TreeNode>();
foreach (Principal p in gp.GetMembers())
{
nodes.Add(new TreeNode(p.Name));
}
treeView.Nodes.AddRange(nodes.ToArray());
【问题讨论】:
标签: c# datagridview active-directory treeview