bourny Posted August 22, 2008 Share Posted August 22, 2008 I am running a script that checks whet domain the machine is part of. This will tell me if the machine is on its own workgroup p.c name or actually part of a domain . I have tried @LogonDNSDomain Logon DNS Domain. @LogonDomain Logon Domain. @LogonServer Logon server. If I am part of a domain called Mydomain.co.uk and log into the machine as a local machine account against the local machine name called "Computer1" the above commands will show "Computer1" "not Mydomain.co.uk" I am looking for a way to find which domain the computer is connected to regardless what it is currently logged in as. I have found some registry areas that state the name of the domain I am looking for but not sure of the consistency of these keys across other platforms.... Keys I found HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\History HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Telephony HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DNSRegisteredAdapters\{9C4CD23B-3AF0-4897-BE2A-3E3E2633FD28} Is there a function / Macro that I am missing in Autoit that I would prefer to use similar to what @LogonDomain would give out Thanks Link to comment Share on other sites More sharing options...
Danny35d Posted August 22, 2008 Share Posted August 22, 2008 $ComputerDomain = _DomainComputerBelongs() MsgBox(0 , @LogonDomain , 'Domain: ' & $ComputerDomain) Func _DomainComputerBelongs($strComputer = "localhost") ; Generated by AutoIt Scriptomatic $Domain = '' $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") If Not IsObj($objWMIService) Then Return SetError(1, 0, '') $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Domain = $objItem.Domain Next Endif Return $Domain EndFunc AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
rasim Posted August 22, 2008 Share Posted August 22, 2008 Easy way: $read = RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", "DefaultDomainName") If $read <> "" Then MsgBox(0, "Info", "Domain name is: " & $read) Link to comment Share on other sites More sharing options...
bourny Posted August 22, 2008 Author Share Posted August 22, 2008 Thanks,,,, I had already identified in the first post I can just read the registry - This is fine however does not provide me with 100% consistency as these values can and have been changed in my scripts especially in the winlogon part of the registry for auto logins etc. I prefer to pull the information in a more structured way .... I think going down APi is the way with objects.... Thanks for your responses... Link to comment Share on other sites More sharing options...
Danny35d Posted August 22, 2008 Share Posted August 22, 2008 Thanks,,,,I had already identified in the first post I can just read the registry - This is fine however does not provide me with 100% consistency as these values can and have been changed in my scripts especially in the winlogon part of the registry for auto logins etc. I prefer to pull the information in a more structured way ....I think going down APi is the way with objects....Thanks for your responses...Try the script from post #2 at work we have two domain with one way trust, depending in which domain the computer is assign to my script runas using different credentials. AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
spudw2k Posted August 22, 2008 Share Posted August 22, 2008 (edited) Try this too. Msgbox(0,GetRootDSE(),FriendlyRootDSE(GetRootDSE())) Func GetRootDSE() $RootDSE = ObjGet("LDAP://RootDSE") If IsObj($RootDSE) Then Return $RootDSE.get( "DefaultNamingContext" ) EndFunc Func FriendlyRootDSE($strRootDSE) $strRootDSE = StringReplace($strRootDSE,"DC=","") $strRootDSE = StringReplace($strRootDSE,",",".") Return $strRootDSE EndFunc Edited August 25, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
bourny Posted August 26, 2008 Author Share Posted August 26, 2008 Try the script from post #2 at work we have two domain with one way trust, depending in which domain the computer is assign to my script runas using different credentials.Thanks.... will be using this script to do what I need to achieve..... I prefer this sort of structured script rather than a registry pull....Will also test this other script from spudw2k.... Thanks again for your input Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now