Check user account password on remote machine

savindrasingh

Board Regular
Joined
Sep 10, 2009
Messages
183
We have list of hundreds of servers located in DMZ and I need a script which can check if the given server is part of a particular domain (for e.g. Microsoft) or its a standalone machine.

If its a standalone machine then further the script should check if that machine has a local user account called "DSSADMIN" with standard password set to "Pa55w0rd".

How this can be done? since the target server is going to be part of workgroup we will not have access to that machine for checking this right? Is there anytihing through which can try to logon to the server with DSSADMIN account with default password and return with a boolean value based on the results.

In short how can we verify a set of username and password on a remote machine in workgroupusing VB.

Hoping for your kind assistance.

Thanks in advance.

I tried below piece of code which will first check if the server is part of Domain and if its not part of domain it shuld try to verify the password. Obviously the second part is not working since the computer is not part of domain so we can't access it with that code. Can anyone help me to replace the piece of code from below code to verify the password on a remote machine in Workgroup.

Code:
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\computerlist.txt", ForReading)
 
Dim arrFileLines()
i = 0
Do Until objFile.AtEndOfStream
 Redim Preserve arrFileLines(i)
 arrFileLines(i) = objFile.ReadLine
 i = i + 1
Loop
objFile.Close
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
 If objFSO.FileExists("c:\output.txt") Then
 
 Else
    Set objFile = objFSO.CreateTextFile("c:\output.txt")
 End If
set objFile = nothing
 
Set objFile = objFSO.OpenTextFile("c:\output.txt", ForWriting)
objFile.Write "Server Name, Domain, DSSAdmin password Current, Comments" & vbCrLf
For Each strComputer in arrFileLines
 On Error Resume Next
 Const HKEY_LOCAL_MACHINE = &H80000002
 strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\"
 strEntryName = "CachePrimaryDomain"
 Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
 objReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
 
 If strValue = "" Then
'===================< Check DSSADMIN password if Machine is Standalone >======================
  [B][COLOR=red]oUser = "DSSADMIN"[/COLOR][/B]
[B][COLOR=red] oPassword = "Pa55w0rd"[/COLOR][/B]
[B][COLOR=red] oDomain = strComputer[/COLOR][/B]
[B][COLOR=red] On Error Resume Next[/COLOR][/B]
[B][COLOR=red] Set objUser = GetObject("WinNT://" & oDomain & "/" & oUser & ", user")[/COLOR][/B]
[B][COLOR=red] objUser.ChangePassword oPassword, oPassword[/COLOR][/B]
[B][COLOR=red] Select Case Err.Number[/COLOR][/B]
[B][COLOR=red]                   Case 0[/COLOR][/B]
[B][COLOR=red]  objFile.Write strComputer & ", Standalone," & " YES," & " Correct Password" & vbCrLf[/COLOR][/B]
[B][COLOR=red]                   Case Else[/COLOR][/B]
[B][COLOR=red]                       objFile.Write strComputer & ", " & err.Number & ", NO," & err.description & vbCrLf[/COLOR][/B]
[B][COLOR=red] End Select[/COLOR][/B]
 Else
  objFile.Write strComputer & ", " & strValue & vbCrLf
 End If
Next
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
To add further to above question, there is password history policy applied on target machine hence we can't verify password using the results we get from below code:

Code:
[B][COLOR=#ff0000]objUser.ChangePassword oPassword, oPassword
[/COLOR][/B]
 
Upvote 0

Forum statistics

Threads
1,225,521
Messages
6,185,463
Members
453,295
Latest member
cheewah0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top