用于检测 Windows Active Directory 名称/IP 的 API
我需要在 Windows 中检测本地和 Active Directory(如果存在)中的所有用户。
我发现 C API:NetQueryDisplayInformation()
还可以选择从“serverName”检索信息,该服务器可能是可以查询的 Active Directory。
但是我如何知道 ActiveDirectory 是否可用/及其名称? 谢谢。
I have a requirement to detect all users from local and Active Directory(if present) in Windows.
I have found that C API: NetQueryDisplayInformation()
has also the option to retrieve the information from a "serverName", which is presumably an Active Directory which can be queried.
But how do I find out if ActiveDirectory is available/ and it's name ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此信息可在 WMI 中找到。在
Win32_ComputerSystem
类(每台计算机只有一个实例)有一个包含域名的Domain
属性。This information is available in WMI. In the
Win32_ComputerSystem
class (there will be a single instance per computer) has aDomain
property containing the domain's name.查找域名(如果存在)的另一种方法是使用 WIN API ::DsGetDcName()
该函数返回 DOMAIN_CONTROLLER_INFO 结构中有关 Active Dir 服务器名称的信息。
您可以在那里获得所需的所有域名信息。比使用 WMI 简单得多:-)
Another way of finding out domain name (if present) is to use WIN API ::DsGetDcName()
This one returns information about Active Dir server name in DOMAIN_CONTROLLER_INFO struct.
You get there all the domain information you need. Much sympler than using WMI :-)