JSI Tip 9543. How can a script determine if a user exists in a remote computers SAM?

Jerold Schulman

July 10, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today


Using the Nltest.exe utility from the Support Tools on the operating system CD-ROM, I have scripted UserExists.bat to determine if a user account is defined in a remote computers SAM (Security Accounts Manager) database.

The syntax for using UserExists.bat is:

call UserExists Computer User YorN

Where:

Computer is the NetBIOS computer name of the remote computer.User     is the user logon name on the remote computer.YorN     is a call directed environment variable that will contain a         Y if the user exists, or an N if the user does NOT exist.

UserExists.bat contains:

@echo offif {%3}=={} @echo Syntax: call UserExists Computer User YorN&goto :EOFset %3=Nfor /f  "Tokens=*" %%a in ('nltest /Server:%1 /User:%2^|Find "User:"') do ( set %3=Y)



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.

You May Also Like