views:

18

answers:

1

I'm trying to detect either by calling an API or using WMI whether a computer is connected to a domain.

I am currently reading the env. variable USERDOMAIN to check whether I am connected to a domain or not but that only works for domains that I know. Is there a better way to see whether I am connected to a LAN/domain?

The code is in C, for windows XP or 7.

thank you.

+1  A: 

Try NetGetJoinInformation. It can give you four results.

NetSetupUnknownStatus  The status is unknown.
NetSetupUnjoined       The computer is not joined.
NetSetupWorkgroupName  The computer is joined to a workgroup.
NetSetupDomainName     The computer is joined to a domain.

torak
thanks. Do you have by any chance a code snippet that shows how to use it?
Mr Aleph
Got it, thanks...
Mr Aleph