Hi,
is there a method to determine if the current pc you're working on is part of a Windows Active Directory domain?
A simple true / false would be sufficient, no further information is needed (what is the name of the Domain Controller you're authenticated with or anything like that)...
Determine if the current pc is part of a domain? Topic is solved
Re: Determine if the current pc is part of a domain? Topic is solved
Code: Select all
MsgBox % NetGetJoinInformation()
NetGetJoinInformation()
{
DllCall("netapi32.dll\NetGetJoinInformation", "ptr", 0, "ptr*", name, "int*", type)
return type, DllCall("netapi32.dll\NetApiBufferFree", "ptr", name)
}
/* https://msdn.microsoft.com/en-us/library/aa370423(v=vs.85).aspx
Return Codes
NetSetupUnknownStatus -> 0 (The status is unknown.)
NetSetupUnjoined -> 1 (The computer is not joined.)
NetSetupWorkgroupName -> 2 (The computer is joined to a workgroup.)
NetSetupDomainName -> 3 (The computer is joined to a domain.)
*/
Re: Determine if the current pc is part of a domain?
Thank you, jNizM!
Re: Determine if the current pc is part of a domain?
Here's another way:
It may be worth familiarising yourself with WMI. You can get a lot of other useful information just by taking this code and replacing the class name (Win32_ComputerSystem) and property names (PartOfDomain, Name, Domain).
You can not only query information, but also make changes, such as by calling pc.UnjoinDomainOrWorkgroup(...).
Code: Select all
for pc in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_ComputerSystem")
if pc.PartOfDomain
MsgBox % pc.Name " is in domain " pc.Domain
else
MsgBox % pc.Name " is not in a domain"
You can not only query information, but also make changes, such as by calling pc.UnjoinDomainOrWorkgroup(...).
Who is online
Users browsing this forum: Dinarid, JoeWinograd, manehscripts, mikeyww, ToJaRedi and 61 guests