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.
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