On a Windows platform, is there any command line utility that I can pass a username
, password
domain name
to in order to verify the credentials (or possibly give an error that the account is disabled, doesn't exist or expired)?
Windows – Windows command line utility to verify user credentials
authenticationcommand-line-interfacecredentialswindows
Best Answer
You could use the
net use
command, specifying the username and password on the command-line (in the formnet use \\unc\path /user:username password
and check theerrorlevel
returned to verify if a credential is valid.The
runas
command would work, too, except that you're going to have a tougher time testing the output.Testing a credential for the existence of an account would be a matter of using
net user
ordsquery
. Thenet user
command won't tell you if an account is locked out, but querying thelockoutTime
attribute of the user account could tell you that.