Mr Aleph
Mr Aleph

Reputation: 1895

Detecting connection to a domain

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.

Upvotes: 1

Views: 98

Answers (1)

torak
torak

Reputation: 5802

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.

Upvotes: 1

Related Questions