WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

NT Native Commands with WinBatch

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How do I retrieve the NT Domain name?

Keywords: domain user domain of client  NT domain  

Question:

Is there a way to determine the name of the NT Domain Controller that is authenticating you? I am planning to write a WB EXE to act as a login script, but for operability ease, I need to determine which Domain Controller the user is being authenticated on so I can taylor the login script for that particular server's location. A little help please??!!

I want WinBatch to retrieve the Domain the user is logged into, and I need to retrieve this information for both Win95 and NT users.

Answer (1 of 2):

HOSTDOM (below) is "domain" of client (workgroup for 95, domain for nt)
MASTDOM (below) is Domain user logged into:

Under 95:

HOSTDOM = RegQueryValue(@REGMACHINE,"System\CurrentControlSet\Services\VxD\VNETSUP[Workgroup]")
MASTDOM = RegQueryValue(@REGMACHINE,"System\CurrentControlSet\Services\MSNP32\NetworkProvider[AuthenticatingAgent]")
USERNAME = RegQueryValue(@REGMACHINE,"Network\Logon[username]")

Under NT:

HOSTDOM=RegQueryValue(@REGMACHINE,"Software\Microsoft\WindowsNT\CurrentVersion\winlogon[CachePrimaryDomain]")
MASTDOM=StrUpper(Environment("USERDOMAIN"))

Answer (2 of 2):

Compile the code below and put it into the NETLOGON directory. In the PROFILES section, make this your login script (Actually, I am writing my own login script, so I can do that!). When the workstation logs in, it runs the program from the path \\servername\netlogon.

This works fine in NT and I will try it in 95. Hope it helps!


CurrentDir=DirGet()
DefaultPath=CurrentDir
WinDir=DirWindows(0)
SysDir=DirWindows(1)
WinPath=DirWindows(0)
WilHome=DirHome()
NetlogonUNC=DirHome()

:GetAuthenticatingServerInfo
ServerString=(StrIndex(NetlogonUNC,"\",3,@fwdscan)-1)
ServerUNC=StrSub(NetlogonUNC,1,ServerString)
ServerName=StrSub(ServerUNC,3,(ServerString-2))

Message("Test","The Current Directory is %CurrentDir%%@crlf%The WIL Home Directory is %WilHome%.%@crlf%NetlogonUNC is %NetlogonUNC%%@crlf%Authenticating Server is %ServerName%.")

Article ID:   W13653
Filename:   Retrieve NT domain name that user is logged into.txt
File Created: 1999:04:15:16:55:28
Last Updated: 1999:04:15:16:55:28