Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Yeah, I can fire up a VM or remote into something and try the password...I know...but is there a tool or script that will simulate a login just enough to confirm or deny that the password is correct?


A server service account's password is "forgotten"...but we think we know what it is. I'd like to pass the credentials to something and have it kick back with "correct password" or "incorrect password".

I even thought about a drive mapping script with that user account and password being passed to see if it mapped the drive successfully or not but got lost in the logic of making it work correctly...something like:

-Script asks for username via msgbox -script asks for password via msgbox -script tries to map a drive to a common share that everyone has access to -script unmaps drive if successful -script returns popup msgbox stating "Correct Password" or else "Incorrect Password"

Any help is'd think this would be a rare occurrence not requiring a tool to support it but...well....

share|improve this question
What OS? What service? – Cristian Ciupitu Sep 23 '09 at 18:58
@Cristian - Windows domain accounts - just verify if the password is correct or not – TheCleaner Sep 23 '09 at 21:04
up vote 14 down vote accepted

JoeWare's command-line auth tool might do the trick.

Haven't used it but it appears to be pretty straightforward.

share|improve this answer
Genius! Perfect for what I needed! Thank you. – TheCleaner Oct 1 '09 at 15:49
I've been looking for a tool like this for years! Simple, straight to the point, but it does what it says it does. give it a domain, user and password and it tells you whether they check out. – Tom Resing Jun 10 '11 at 21:34
Just wanted to say thanks again after all these years...this tool still comes in handy all the time! – TheCleaner May 30 '13 at 15:47
TROJAN VIRUS WARNING: As of the date of this comment, the file referenced for download was blocked by our corporate SonicWALL's AV, identified as a trojan horse virus: "MalUAgent.MIP (Trojan)" – Emeraldo Sep 24 '14 at 18:06
runas /u:yourdomain\a_test_user notepad.exe

The utility will prompt for the password, if the right password has been provided, notepad will launch, if not it will produce error 1326: the username or password is incorrect

share|improve this answer
Clever Roberto. +1 – TheCleaner Oct 10 '14 at 1:43
Simple. Elegant. I like it. – Lopsided Mar 4 '15 at 22:48
Awesome! This solution has two important advantages over the accepted answer: 1) available on Windows XP+ out of the box, don't have to download anything, 2) related to this: as it's from MS, it doesn't require me to trust my password to some third-party tool of unknown provenance. – akavel May 19 '15 at 10:16
Fast, clean and simple! Thank you! – juFo May 26 '15 at 7:16
Serverfault IT admins know this, but if you're a home user finding this answer off a web search (this is the best answer by the way–uses only stuff that comes with Windows): on a home computer, the yourdomain part above is your computer's name. Find that in Control Panel > System. One of the values is literally that, "Computer Name:". E.g. if you're computer's name is "smith-laptop" and your username is "joe", you'd do runas /u:smith-laptop\joe notepad.exe – Daryn Nov 13 '15 at 7:25

You can also use:

net use \\computername\sharename [password] /USER:]username]

If there's a share by that name on the remote computer. Or, use C$ if the account is an admin.

share|improve this answer

Powershell script:

#usage: Test-UserCredential -username UserNameToTest -password (Read-Host)

Function Test-UserCredential { 
    Param($username, $password) 
    Add-Type -AssemblyName System.DirectoryServices.AccountManagement 
    $ct = [System.DirectoryServices.AccountManagement.ContextType]::Machine, $env:computername 
    $opt = [System.DirectoryServices.AccountManagement.ContextOptions]::SimpleBind 
    $pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext -ArgumentList $ct 
    $Result = $pc.ValidateCredentials($username, $password).ToString() 

share|improve this answer

You can write an easy vbscript function which can verify this...something like:

Function GoodPassword(strAdminUsername, strAdminPassword, strNTDomain)

    On Error Resume Next
    Set objIADS = GetObject("WinNT:").OpenDSObject("WinNT://" & _
                        strNTDomain, strAdminUserame, _
                        strAdminPassword, _
    if err.number = 0 then
       GoodPassword = True
       GoodPassword = False
    End If
    On Error GoTO 0
End Function


share|improve this answer
Please note this will lock an account out after 'n' amount failed logins, 'n' being whatever policy you have set. This should always be true of any solution which you use. – mrTomahawk Oct 1 '09 at 15:31

You could use one of the many well known tools out there to test passwords. One I saw is L0phtcrack. Maybe there is even a way to do this offline with a dump of you authentication database. In "the other world", we use "john the ripper" for stuff like this.

share|improve this answer
I'm not talking about cracking passwords or testing their strength. I'm talking about a tool that can tell me if the password I enter for a particular account is that account's password. – TheCleaner Sep 22 '09 at 18:07
@TheCleaner: Sure, you can create a word-list with all possible passwords for a specific account and use this list for a set of accounts. or a single one... Testing with SMB or something is a rather bad idea. It fills your logs, messes up sessions to the file server, generates load on DCs and file servers and so on. – PEra Sep 29 '09 at 19:16

Using code from above, check all domain accounts to see if they are using a certain password.

$usernames = Get-ADUser -Filter * | select -ExpandProperty SamAccountName

foreach ($username in $usernames) {
$password = "Password"
Add-Type -AssemblyName System.DirectoryServices.AccountManagement 
$ct = [System.DirectoryServices.AccountManagement.ContextType]::Machine, $env:computername 
$opt = [System.DirectoryServices.AccountManagement.ContextOptions]::SimpleBind 
$pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext -ArgumentList $ct 
$Result = $pc.ValidateCredentials("domain\$username", $password).ToString() 
If ($Result -eq "True") {echo "$username" >> C:\result.txt}
share|improve this answer

Why not use a network service with authentication (telnet, POP, IMAP, SMTP, what you want) ? Other side, if you are on the machine you can try su - userToTest from a non priv account. If the password is OK, you will be allowed in the userToTest homedir if the shell allow the connection

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.