获取 Windows 组成员及其域名
我有一个名为“windgrp”的 Windows 组,其中包含三个成员:
- 管理员
- testDomain.Administrator
- user1
我有以下代码来显示组中存在的成员:
using (DirectoryEntry groupEntry =
new DirectoryEntry("WinNT://./" + userGroupName + ",group"))
{
foreach (object member in (IEnumerable)groupEntry.Invoke("Members"))
{
using (DirectoryEntry memberEntry = new DirectoryEntry(member))
{
listbox.itms.add(memberentry.name);
}
}
}
这给了我结果:
- 管理员
- 管理员
- 用户
它不< /em> 显示第二个条目属于哪个域。
如何获得域名?
I have a windows group called "windgrp" it has three members in it:
- Administrators
- testDomain.Administrator
- user1
I have this code to display the members present in a group:
using (DirectoryEntry groupEntry =
new DirectoryEntry("WinNT://./" + userGroupName + ",group"))
{
foreach (object member in (IEnumerable)groupEntry.Invoke("Members"))
{
using (DirectoryEntry memberEntry = new DirectoryEntry(member))
{
listbox.itms.add(memberentry.name);
}
}
}
This gives me the result:
- Administrator
- Administrator
- user
It does not show me to which domain the 2nd entry belongs to.
How can I get the domain?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要沿着对象的层次结构向上走。因此,如果您有您的用户,您可以从那里开始递归,寻找满足您的搜索条件的模式类。
You need to walk up the hierarchy of objects. So if you have your user, you can start recursion from there up, looking for schema classes that satisfy your search criteria.