Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
November 3, 2005
I have scripted uDN.bat to retrieve the distinguishedName of the logged on user.
The syntax for using uDN.bat is:
call uDN DN
Where DN is a call directed environment variable that will contain the logged on user's distinguishedName, like "CN=Jerold Schulman,CN=Users,DC=JSIINC,DC=COM".
uDN.bat contains:
@echo offif {%1}=={} @echo Syntax: uDN DN&goto :EOFif exist "%TEMP%uDN.VBS" goto [email protected] objSysInfo = CreateObject("ADSystemInfo")>"%TEMP%uDN.VBS"@echo.sUser =
" ^& objSysInfo.UserName ^&
">>"%TEMP%uDN.VBS"@echo.WScript.Echo sUser>>"%TEMP%uDN.VBS":getDNfor /f "Tokens=*" %%u in ('cscript //nologo "%TEMP%uDN.VBS"') do ( set %1=%%u)
You May Also Like