/build/static/layout/Breadcrumb_cap_w.png

Win PE script to authenticate user ldap

I have made a script to authenticate a user from a PE environment but I have run into a snag. on line 60 character 1 it errors out.
Any help would be appreciated.


Dim objRootDSE, strConfig, objConnection, objCommand, strQuery
Dim objRecordSet, objDC, objSite
Dim fso, WshNetwork, sUser, oUser, sPassword, sDomain, oDomain, mappedDrive, drive
Dim objDictionary, strComputer, objWMIService, objDisk, strDrive, freeDrive, colDisks, i
Dim WSHShell ' declare the object variable
Dim Message
Dim Title
'*** Here we may localize the strings ***
language= 0 ' 0 = English, 1 = German
' Here we initialize the variables for user interaction
If language = 0 Then ' *** English ***
Message = "Please enter username"
Title = "CMHC-NT Login"
Text1 = "Sorry, user input was canceled"
Text2 = "I got the input:" + vbCRLF
End If
Set WSHShell = WScript.CreateObject("WScript.Shell")
sUser = InputBox(Message,Title,"username", 100, 100)
If sUser = "" Then
WScript.Echo Text1
Else
'WScript.Echo Text2 + sUser
End If
'WScript.Quit()
language= 0 ' 0 = English, 1 = German
' Here we initialize the variables for user interaction
If language = 0 Then ' *** English ***
Message = "Please enter pasasword"
Title = "CMHC-NT Login"
Text1 = "Sorry, user input was canceled"
Text2 = "I got the input:" + vbCRLF
End If
Set WSHShell = WScript.CreateObject("WScript.Shell")
sPassword = InputBox(Message,Title,"password", 100, 100)
If sPassword = "" Then
WScript.Echo Text1
Else
'WScript.Echo Text2 + sPassword
End If
language= 0 ' 0 = English, 1 = German
' Here we initialize the variables for user interaction
If language = 0 Then ' *** English ***
Message = "Change Domain if needed otherwise press Enter"
Title = "CMHC-NT Login"
Text1 = "Sorry, user input was canceled"
Text2 = "I got the input:" + vbCRLF
End If
Set WSHShell = WScript.CreateObject("WScript.Shell")
sDomain = InputBox(Message,Title,"CMHC-NT", 100, 100)
If sDomain = "" Then
WScript.Echo Text1
Else
'WScript.Echo Text2 + sDomain
End If
'Set oArgs = WScript.Arguments
Set oDomain = GetObject("WinNT://" & sDomain)
oDomain.Filter = Array("user")
For Each oUser In oDomain
If LCase(oUser.Name) = LCase(sUser) Then
Set objDictionary = CreateObject("Scripting.Dictionary")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery("Select * from Win32_LogicalDisk")
For Each objDisk in colDisks
objDictionary.Add objDisk.DeviceID, objDisk.DeviceID
Next
WDSDrive = "Empty"
For i = 67 to 90
strDrive = Chr(i) & ":"
If objDictionary.Exists(strDrive) Then
Else
'Wscript.Echo strDrive & " is the next available drive letter."
WDSDrive = strDrive
Exit For
End If
Next
If WDSDrive = "Empty" Then
Else
' Determine configuration context from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfig = objRootDSE.Get("configurationNamingContext")
' Use ADO to search Active Directory for ObjectClass nTDSDSA.
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strQuery = "<LDAP://" & strConfig _
& ">;(ObjectClass=nTDSDSA);AdsPath;subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
' creating file system objects
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshNetwork = WScript.CreateObject("WScript.Network")
' The parent object of each object with ObjectClass=nTDSDSA is a Domain
' Controller. The parent of each Domain Controller is a "Servers"
' container, and the parent of this container is the "Site" container.
Do Until objRecordSet.EOF
Set objDC = GetObject( _
GetObject(objRecordSet.Fields("AdsPath")).Parent)
Set objSite = GetObject(GetObject(objDC.Parent).Parent)
On Error Resume Next
'WshNetwork.MapNetworkDrive WDSDrive, "\\" & objDC.cn & "\netlogon",false,sDomain & "\" & sUser, sPassword
'If fso.FolderExists(WDSDrive) Then
'WshNetwork.RemoveNetworkDrive WDSDrive
If MemberOf(ObjGroupDict, "IS TECHS") Then
If FSO.DriveExists("I:") Then
WSHNetwork.RemoveNetworkDrive "I:"
WSHNetwork.MapNetworkDrive "I:", "\\cmh-ris\REMINST\Images"
Else
WSHNetwork.MapNetworkDrive "I:", "\\cmh-ris\REMINST\Images"
' End If
End If

Wscript.Echo "SUCCESS"
Dim oShell
Set oShell= CreateObject("Wscript.Shell")
Set oEnv = oShell.Environment("PROCESS")
oEnv("SEE_MASK_NOZONECHECKS") = 1
oShell.run "c:\windows\system32\image.bat",6,TRUE
Set oShell = Nothing
wscript.Quit(0)
End If
objRecordSet.MoveNext
Loop
Wscript.Echo "Password is wrong"
Set WSHShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"

Wscript.Quit(1)
' Clean up.
objConnection.Close
Set objRootDSE = Nothing
Set objCommand = Nothing
Set objConnection = Nothing
Set objRecordSet = Nothing
Set objDC = Nothing
Set objSite = Nothing
End If
End If
Next
Wscript.Echo "username is wrong"
Set WSHShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"

0 Comments   [ + ] Show comments

Answers (1)

Posted by: taz081175 15 years ago
Senior Yellow Belt
0
all I am really looking for is a way in Win PE. is to have the user authenticate to the network and be part of a specific group. It is a precaution so an ordinary user does not PXE boot and wipe out their hard drive from the WDS server.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ