In tip 7680, we determined the distinguished name of the forest root domain.
in tip 8540, we scripted DomainDN.bat to retrieve the distinguished name of the domain you are logged on to using the DSQUERY Active Directory command-line tool.
I have scripted DomainDN.bat to retrieve the distinguished name of the domain you are logged on to using standard commands.
The syntax for using DomainDN.bat is:
DomainDN DN
Where DN is a call directed environment variable that will contain the distinguished name of the domain you are logged on to.
Example:
When I use DomainDN DN, DN is set to DC=JSIINC,DC=COM.DomainDN.bat contains:
@echo off if \{%1\}==\{\} @echo Syntax Call DomainDN DomainName&exit /b 1 if exist "%TEMP%\DomainDN.vbs" goto doit @echo Set objRootDSE = GetObject("LDAP://rootDSE")>"%TEMP%\DomainDN.vbs" @echo strDomain = objRootDSE.Get("defaultNamingContext")>>"%TEMP%\DomainDN.vbs" @echo Wscript.Echo strDomain>>"%TEMP%\DomainDN.vbs" :doit for /f "Tokens=* Delims=:" %%c in ('cscript //Nologo "%TEMP%\DomainDN.vbs"') do set %1=%%c exit /b 0
0 comments
Hide comments