开发者

API for Detecting Windows Active Directory name/IP

开发者 https://www.devze.com 2023-03-27 21:28 出处:网络
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

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.


This information is available in WMI. In the Win32_ComputerSystem class (there will be a single instance per computer) has a Domain property containing the domain's name.


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 :-)

0

精彩评论

暂无评论...
验证码 换一张
取 消