Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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)?

share|improve this question
1  
Why would you need to verify anyone's credentials but your own. As a responsible and respectable SysAd, you have no need to know anyone else's credentials (except perhaps root or the Domain Admin accounts). –  gWaldo Jul 23 '12 at 10:34
2  
@gWaldo: I came here as a software engineer who is writing an installer program which asks a user for the credentials of an existing machine account, which we then subsequently store (encrypted) for code-level Win32 API impersonation calls. I found this question and answer relevant and useful, as well as legitimate. –  Mike Atlas Oct 10 '12 at 13:44

2 Answers 2

up vote 4 down vote accepted

You could use the net use command, specifying the username and password on the command-line (in the form net use \\unc\path /user:username password and check the errorlevel 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 or dsquery. The net user command won't tell you if an account is locked out, but querying the lockoutTime attribute of the user account could tell you that.

share|improve this answer

In Powershell:

Function Test-ADAuthentication {
    param($username,$password)
    (new-object directoryservices.directoryentry "",$username,$password).psbase.name -ne $null
    }

PS C:\> Test-ADAuthentication "dom\myusername" "mypassword"
True
PS C:\>

Reference: http://stackoverflow.com/questions/7663219/how-to-authenticate-an-user-in-activedirectory-with-powershell

share|improve this answer

Your Answer

 
discard

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.