如何获取所有Windows组?
我写这个是为了获取特定用户所属的组:
DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
DirectoryEntry user = AD.Children.Find(completeUserName, "user");
object obGroups = AD.Invoke("Groups");
foreach (object ob in (IEnumerable)obGroups)
{
// Create object for each group.
DirectoryEntry obGpEntry = new DirectoryEntry(ob);
listOfMyWindowsGroups.Add(obGpEntry.Name);
}
for (int j = 0; j < listOfMyWindowsGroups.Count; j++)
{
//ex
}
How is it possible toretrieve all the groups in windows while not just for a certain user?
I wrote this to get the groups a particular user belongs to:
DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
DirectoryEntry user = AD.Children.Find(completeUserName, "user");
object obGroups = AD.Invoke("Groups");
foreach (object ob in (IEnumerable)obGroups)
{
// Create object for each group.
DirectoryEntry obGpEntry = new DirectoryEntry(ob);
listOfMyWindowsGroups.Add(obGpEntry.Name);
}
for (int j = 0; j < listOfMyWindowsGroups.Count; j++)
{
//ex
}
How is it possible to retrieve all the groups in windows and not just for a particular user?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如何为组设置过滤器并枚举结果?
试试这个过滤器:
How about setting up a filter for groups and enumerating the results.
Try this filter:
尝试一下这个,它会为您提供指定 OU 中的所有组。
如需完整参考,您可以查看
.Net 3.5 版本 - > http://anyrest.wordpress.com/2010/06/28/ active-directory-c/
旧版本 - > http://anyrest.wordpress.com/2010/ 02/01/active-directory-objects-and-c/
Try this one out, it will give you all groups in a specicied OU.
For a full reference you can check this one out
.Net 3.5 version - > http://anyrest.wordpress.com/2010/06/28/active-directory-c/
Older versions - > http://anyrest.wordpress.com/2010/02/01/active-directory-objects-and-c/