@@ -18,10 +18,10 @@ Option Explicit
1818Dim FBManageSecurity: Set FBManageSecurity = New FBManageSecurityClass
1919
2020Class FBManageSecurityClass
21- Dim objADOCmd, objADOConn, objExec, objFolder, objFSO, objFW, objFWRules, objRecordSet, objSDUtil, objShell, objWMIReg
21+ Dim objADOCmd, objADOConn, objLookup, objLookupFile, objExec, objFolder, objFSO, objFW, objFWRules, objRecordSet, objSDUtil, objShell, objWMIReg
2222Dim arrProfFolders, arrProfUsers
2323Dim intIdx, intBuiltinDomLen, intNTAuthLen, intServerLen
24- Dim strBuiltinDom, strClusterName, strCmd, strCmdSQL, strDirSystemDataBackup
24+ Dim strBuiltinDom, strClusterName, strCmd, strCmdSQL, strLookupFile, strLookupPassword, strLookupXML, strDirSystemDataBackup
2525Dim strGroupDBA, strGroupDBANonSA, strGroupMSA, strHKLM, strHKU, strIsInstallDBA, strKeyPassword, strLocalAdmin
2626Dim strNTAuth, strOSVersion, strPath, strProfDir, strProgCacls, strProgReg
2727Dim strServer, strSIDDistComUsers, strSSLCert, strSSLCertFile, strSSLCertThumb, strSystemDataSharedPrimary
@@ -33,6 +33,7 @@ Private Sub Class_Initialize
3333
3434 Set objADOConn = CreateObject( "ADODB.Connection" )
3535 Set objADOCmd = CreateObject( "ADODB.Command" )
36+ Set objLookup = CreateObject( "MSXML2.DomDocument" )
3637 Set objFSO = CreateObject( "Scripting.FileSystemObject" )
3738 Set objFW = CreateObject( "HNetCfg.FwPolicy2" )
3839 Set objFWRules = objFW.Rules
@@ -45,12 +46,15 @@ Private Sub Class_Initialize
4546 strBuiltinDom = GetBuildfileValue( "BuiltinDom" )
4647 strClusterName = GetBuildfileValue( "ClusterName" )
4748 strCmdSQL = GetBuildfileValue( "CmdSQL" )
49+
4850 strDirSystemDataBackup = GetBuildfileValue( "DirSystemDataBackup" )
4951 strGroupDBA = GetBuildfileValue( "GroupDBA" )
5052 strGroupDBANonSA = GetBuildfileValue( "GroupDBANonSA" )
5153 strGroupMSA = GetBuildfileValue( "GroupMSA" )
5254 strIsInstallDBA = GetBuildfileValue( "IsInstallDBA" )
5355 strKeyPassword = GetBuildfileValue( "KeyPassword" )
56+ strLookupFile = GetBuildfileValue( "LookupFile" )
57+ strLookupPassword = GetBuildfileValue( "LookupPassword" )
5458 strLocalAdmin = GetBuildfileValue( "LocalAdmin" )
5559 strNTAuth = GetBuildfileValue( "NTAuth" )
5660 strOSVersion = GetBuildfileValue( "OSVersion" )
@@ -76,6 +80,26 @@ Private Sub Class_Initialize
7680 objADOConn.Open "ADs Provider"
7781 Set objADOCmd.ActiveConnection = objADOConn
7882
83+ ' Code based on https://stackoverflow.com/questions/28352141/convert-a-secure-string-to-plain-text
84+ strLookupXML = "<ROOT/>"
85+ Select Case True
86+ Case strLookupFile = ""
87+ ' Nothing
88+ Case CheckFile(strLookupFile) = False
89+ ' Nothing
90+ Case Else
91+ Set objLookupFile = objFSO.OpenTextFile(strLookupFile, 1 )
92+ strLookupXML = objLookupFile.ReadAll
93+ If strLookupPassword <> "" Then
94+ ' TO DO: Convert encrypted secure string version of strLookupXML to plaintext xml using Powershell. Some possible code shown below:
95+ ' strCmd = "$LookupXML = Convert-To-SecureString '" & strLookupXML & "' ;"
96+ ' strCmd = strCmd & "$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($LookupXML) ;"
97+ ' strCmd = strCmd & "[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"
98+ ' strLookupXML = GetPSData(strCmd)
99+ End If
100+ End Select
101+ objLookup.LoadXml(strLookupXML)
102+
79103 intBuiltinDomLen = Len(strBuiltinDom) + 1
80104 intNTAuthLen = Len(strNTAuth) + 1
81105 intServerLen = Len(strServer) + 1
@@ -453,19 +477,27 @@ End Function
453477
454478Function GetCredential(strPassword, strAccount)
455479 Call DebugLog( "GetCredential: " & strPassword)
456- Dim strAcctName
480+ Dim strAcctName, strCredential
457481
458- GetCredential = GetBuildfileValue(strPassword)
482+ strCredential = GetBuildfileValue(strPassword)
459483 Select Case True
460- Case LCase(GetCredential ) <> "encrypted "
484+ Case LCase(strCredential ) <> "lookup "
461485 ' Nothing
462486 Case strAccount = ""
463- ' Get credential from Password file
487+ strCredential = GetXMLParm(objLookup, UCase(strPassword), "lookup" )
464488 Case Else
465489 strAcctName = GetBuildfileValue(strAccount)
466- ' Get credential from Password file
490+ If Instr(strAcctName, "\" ) > 0 Then
491+ strAcctName = Mid(strAcctName, Instr(strAcctName, "\" ) + 1 )
492+ End If
493+ If Instr(strAcctName, "@" ) > 0 Then
494+ strAcctName = Left(strAcctName, Instr(strAcctName, "@" ) - 1 )
495+ End If
496+ strCredential = GetXMLParm(objLookup, UCase(strAcctName), "lookup" )
467497 End Select
468498
499+ GetCredential = strCredential
500+
469501End Function
470502
471503
0 commit comments