I had to come up with a way to vaildate some domain user credentials for a support package. Here’s the code in it’s simplest vbs form :
‘“““““““““““““““““““““““““““““
Dim objDSO, objDomain, objSysInfo, strDomain
Set objSysInfo = CreateObject(”ADSystemInfo”)
strDomain = objSysInfo.DomainShortName
Set objDSO = GetObject(”WinNT:”)
On Error Resume Next
Set objDomain = objDSO.OpenDSObject(”WinNT://” & strDomain, “username”, “password”, ADS_SECURE_AUTHENTICATION)
If Err.Number <> 0 Then
Select Case Err.Number
Case -2147023570
MsgBox “Unknown user name or password.”, 64, “Windows Authentication”
Case -2147022987
MsgBox “User account is locked.”, 64, “Windows Authentication”
Case -2147023565
MsgBox “User account is disabled.”, 64, “Windows Authentication”
Case Else
MsgBox “Unknown error, unable to verify credentials.” & vbCRLF & _
“Error Code: ” & Err.Number, 64, “Windows Authentication”
End Select
Set objDSO = Nothing
Set objDomain = Nothing
Set objSysInfo = Nothing
Wscript.Quit
End If
Set objDSO = Nothing
Set objDomain = Nothing
Set objSysInfo = Nothing
MsgBox “Credentials verified.”, 64, “Windows Authentication”