#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=C:\Program Files\AutoIt3\Icons\My.ico #AutoIt3Wrapper_Outfile=CacheCredentials.exe #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseAnsi=y #AutoIt3Wrapper_Res_Comment=Creates local profile and caches credentials #AutoIt3Wrapper_Res_Description=Caches user credentials locally on the Windows machine #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_LegalCopyright=Dell Inc. #AutoIt3Wrapper_Res_Language=1033 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** $oMyError = ObjEvent("AutoIt.Error", "ComError") #include #include #include #include #include #include ; File functions #include ; Array functions #include ;FileInstall("DAEUI.jpg", "DAEUI.jpg", 1) Dim $uname, $domain, $pword, $DADDrive $domain = "My Domain" $LogFile = @ScriptDir & "\CacheCredentials.Log" $ModuleName = "CacheCredentials" $StatusCode = 0 $StatusMessage = $ModuleName & " completed successfully" _FileWriteLog($LogFile, "Start " & @ScriptFullPath) _UserForm() _CacheCreds() Func _UserValidate($UserName, $Password) SplashTextOn("Automated Deployment", "Verifying username and password, please wait...", -1, 20, -1, -1, 32, "", 12) Local $NameSpace = ObjGet("WinNT:") Local $ADS_SECURE_AUTHENTICATION = 0x0001 ; Check the userid/password combination and on error return a 0 Local $DomObj = $NameSpace.OpenDSObject("WinNT://" & $domain, $UserName, $Password, $ADS_SECURE_AUTHENTICATION) $retcode = @error If $retcode = 0 Then _FileWriteLog($LogFile, "Credentials were verified!") SplashOff() _CacheCreds() Else SplashOff() _FileWriteLog($LogFile, "Could not verify entered credentials, prompt to retry or cancel") $retcode = MsgBox(53, "", "Could not verify credentials" & @CRLF & "Click OK to Retry") If $retcode = 4 Then _FileWriteLog($LogFile, "Retrying, prompt again") _UserForm() Else _FileWriteLog($LogFile, "User cancelled, start DAD and fail task") _FileWriteLog($LogFile, "Write profileerror.txt flag") $PFError = FileOpen("profileerror.txt", 2) FileClose($PFError) ;_StartDAD() Exit EndIf EndIf EndFunc ;==>_UserValidate ;COM Error function Func ComError() If IsObj($oMyError) Then $HexNumber = Hex($oMyError.number, 8) SetError($HexNumber) Else SetError(1) EndIf Return 0 EndFunc ;==>ComError Func _CacheCreds() SplashTextOn("Automated Deployment", "Creating local profile, please wait...", -1, 20, -1, -1, 32, "", 12) _FileWriteLog($LogFile, "Caching credentials...") RunAs($uname, $domain, $pword, 1, "ipconfig.exe", @SystemDir, @SW_HIDE) $retcode = @error _FileWriteLog($LogFile, "Return code = " & $retcode) If $retcode <> 0 Then _FileWriteLog($LogFile, "Error caching credentials") SplashOff() Else ProcessWait("ipconfig.exe", 300) Sleep(1000) ProcessClose("ipconfig.exe") SplashOff() _FileWriteLog($LogFile, "Credentials successfully cached!") EndIf ;_StartDAD() EndFunc ;==>_CacheCreds Func _WriteStatus();Create the status.xml file that the DAD Engine (DAE.EXE) will use to determine success or failure. $Date = @MON & "-" & @MDAY & "-" & @YEAR ; Gets the current date $Time = @HOUR & ":" & @MIN & ":" & @SEC ; Gets the current time #Region *** Creates a copy of what is about to be written to the status.xml file inside of the Module log file *** _FileWriteLog($LogFile, "Gathered the following module information...") _FileWriteLog($LogFile, " ModuleName: " & $ModuleName) _FileWriteLog($LogFile, " Execution Date: " & $Date) _FileWriteLog($LogFile, " Execution Time: " & $Time) _FileWriteLog($LogFile, " Execution Status Code: " & $StatusCode) _FileWriteLog($LogFile, " Execution Status Message: " & $StatusMessage) #EndRegion *** Creates a copy of what is about to be written to the status.xml file inside of the Module log file *** _FileWriteLog($LogFile, "_WriteStatus function has been started");Writes to the module log file $file = FileOpen($DADDrive & ":\distribution\engines\dae\status.xml", 2);Opens status.xml. The , 2 = Write mode (erase previous contents) If $file = -1 Then;Makes sure the open status.xml worked on the above line _FileWriteLog($LogFile, "Error opening status.xml");Writes to the module log file $StatusMessage = "Can't open status.xml for writing";Sets the value of the message to be written to status.xml if we failed to open status.xml. (I know...I know) EndIf FileWrite($file, "" & @CRLF) FileWrite($file, " " & $ModuleName & "" & @CRLF) FileWrite($file, " " & $Date & "" & @CRLF) FileWrite($file, " " & @CRLF) FileWrite($file, " " & $StatusCode & "" & @CRLF) FileWrite($file, " " & $StatusMessage & "" & @CRLF) FileWrite($file, " 0" & @CRLF) FileWrite($file, "" & @CRLF) FileClose($file) Exit EndFunc ;==>_WriteStatus Func _Submit() $retcode = ControlClick("Please enter your Username and Password", "", "[CLASS:Button; TEXT:Submit; INSTANCE:1]") EndFunc ;==>_Submit