如何快速确定Windows客户端是否未附加到Active Directory域 [英] How can I quickly identify if windows client is NOT attached to an Active Directory Domain

查看:63
本文介绍了如何快速确定Windows客户端是否未附加到Active Directory域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪些Win32 API(或任何技术)可以帮助我快速确定Windows客户端是否未附加到Active Directory域?

What Win32 API (or any technique) can help me quickly identify if the windows client is NOT attached to an Active Directory Domain?

我使用Windows脚本宿主UserDomain进行的测试如果未登录到Active Directory域,则始终返回本地计算机信息.如果不登录到Active Directory域,我希望抛出错误或返回空白.

My tests with Windows Scripting Host UserDomain always return the local machine info if not logged into an Active Directory Domain. I want either an error to be thrown or a blank to be returned if not logged into an Active Directory Domain.

我现在可以找出答案,但是通常我会有30秒的延迟,直到ADSI查询失败为止,然后我将其适当地捕获并处理.

请注意,我的应用程序是用MS Office内的VBA编写的,并且将从那里调用Win32 API调用,因此,将不胜感激VBA中的任何示例代码.

I can find out now, but I typically have a 30 second delay until the ADSI query fails which I then trap and handle appropriately.

Note that my application is written in VBA within MS Office, and the Win32 API call will be invoked from there, so any example code in VBA would be appreciated.

推荐答案

尝试 NetGetJoinInformation函数.对于不在AD中的计算机,您可以在out参数中看到NetSetupDomainName以外的任何内容.

Try NetGetJoinInformation Function. You can expect anything but NetSetupDomainName in the out param for the computers not in AD.

我不是VBA专家,您可能希望首先在小型C代码中使用此API,以了解获取信息所需的时间.

I am not a VBA expert, you may want to use this API in a small C code first to findout what time it takes to get you the information.


这篇关于如何快速确定Windows客户端是否未附加到Active Directory域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆