BB |
Regular |
|
|
Joined: Jun 23, 2004 |
Posts: 340 |
|
|
|
|
|
|
|
|
How do I find the name of my Primary Domain Controller in the PDC, and how do I find out which domain controller I logged into? The answer is in VBScript.
Copy the following code into notepad and save it as a file called "findDC.vbs"
Code: | REM if the clients are W2k or above, the ADSystemInfo object has SiteName and
REM GetAnyDCName. If the offices are each in a defined site, then SiteName would
REM be good. I can't find documentation on GetAnyDCName, but I think it will be
REM the DC that responds first. It will be the DNS name in the form similar to
REM MyServer.MyDomain.com.
Set objSysInfo = CreateObject("ADSystemInfo")
Wscript.Echo "ADSystemInfo.SiteName.:" & objSysInfo.SiteName
Wscript.Echo "ADSystemInfo.SiteName.GetAnyDCName:" & objSysInfo.GetAnyDCName
REM If the client is NT or above, you can retrieve the environment variable
REM %LOGONSERVER%, in the form \\MyServer:
Set objShell = CreateObject("Wscript.Shell")
Wscript.Echo "Wscript.Shell.Environment.Process.LogonServer:" & objShell.Environment("Process").Item("LogonServer" )
REM Finally, on any client (Windows 95 or above, with DSClient), the RootDSE
REM object can retrieve ServerName:
Set objRootDSE = GetObject("LDAP://RootDSE")
Wscript.Echo "LDAP://RootDSE . ServerName:" & objRootDSE.ServerName
REM The last will be similar to
REM "cn=MyServer,cn=servers,cn=MySite,cn=sites,cn=conf iguration,dc=MyDomain,dc=c
REM om", so you have to parse it for the DC name.
REM There is also WinNTSystemInfo.PDC, but it seems to only be available on W2k
REM and above:
Set objNTInfo = CreateObject("WinNTSystemInfo")
Wscript.Echo "WinNTSystemInfo.PDC:" & objNTInfo.PDC |
Save the code and open a command prompt in the directory where you saved the file. If you saved it in C:\My Documents, do Start Menu -- run -- cmd. Then cd \"My Documents"
At the command prompt, type
The output will look like this
Quote: | ADSystemInfo.SiteName.:YourSite
ADSystemInfo.SiteName.GetAnyDCName:YourBDC.tree.domain
Wscript.Shell.Environment.Process.LogonServer:\\YourBDC
LDAP://RootDSE . ServerName:CN=YourBDC,CN=Servers,CN=YourSite,CN=Sites,
nfiguration,DC=ds,DC=uhc,DC=com
WinNTSystemInfo.PDC:YourPDC |
|
|