Reg value for the machine account's domain

P

Paul D.

Can anyone tell me where the registry value for the machine account's Domain
is located? Thanks in advance...

- - - -
Paul D.
 
J

Jerold Schulman

Can anyone tell me where the registry value for the machine account's Domain
is located? Thanks in advance...

- - - -
Paul D.
I believe you match the data value in
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\CachePrimaryDomain
against a Value Name in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DomainCache
to extract the full domain name.



Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
T

Torgeir Bakken \(MVP\)

Paul said:
Can anyone tell me where the registry value for the machine
account's Domain is located? Thanks in advance...
Hi

As far as I know, there is no "safe" place in registry to read this from.

Parse the output from "net.exe config workstation" in a batch file, or
use VBScript/WMI.


Batch file (do *not* remove the spaces in "workstation domain "):

'--------------------8<----------------------
@echo off
for /f "tokens=3" %%a in (
'net.exe config workstation^|find.exe /i "workstation domain "') do set domain=%%a
echo %domain%
'--------------------8<----------------------



VBScript/WMI:

'--------------------8<----------------------
sNode = "." ' use "." for local computer
Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & sNode & "\root\cimv2")
Set colComputer = oWMI.ExecQuery _
("Select DomainRole, Domain from Win32_ComputerSystem")
For Each oComputer in colComputer
iDR = oComputer.DomainRole
sName = oComputer.Domain
Next

If iDR = 0 Or iDR = 2 Then
WScript.Echo "Computer is in workgroup " & sName
Else
WScript.Echo "Computer is in domain " & sName
End If
'--------------------8<----------------------
 
T

Torgeir Bakken \(MVP\)

Jerold said:
I believe you match the data value in
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\CachePrimaryDomain
against a Value Name in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DomainCache
to extract the full domain name.
Hi

But I would think this would give you the domain for the user
account, and not necessarily the machine account domain, right?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top