@@ -18,10 +18,10 @@ Option Explicit
18
18
Dim FBManageSecurity: Set FBManageSecurity = New FBManageSecurityClass
19
19
20
20
Class 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
22
22
Dim arrProfFolders, arrProfUsers
23
23
Dim intIdx, intBuiltinDomLen, intNTAuthLen, intServerLen
24
- Dim strBuiltinDom, strClusterName, strCmd, strCmdSQL, strDirSystemDataBackup
24
+ Dim strBuiltinDom, strClusterName, strCmd, strCmdSQL, strLookupFile, strLookupPassword, strLookupXML, strDirSystemDataBackup
25
25
Dim strGroupDBA, strGroupDBANonSA, strGroupMSA, strHKLM, strHKU, strIsInstallDBA, strKeyPassword, strLocalAdmin
26
26
Dim strNTAuth, strOSVersion, strPath, strProfDir, strProgCacls, strProgReg
27
27
Dim strServer, strSIDDistComUsers, strSSLCert, strSSLCertFile, strSSLCertThumb, strSystemDataSharedPrimary
@@ -33,6 +33,7 @@ Private Sub Class_Initialize
33
33
34
34
Set objADOConn = CreateObject( "ADODB.Connection" )
35
35
Set objADOCmd = CreateObject( "ADODB.Command" )
36
+ Set objLookup = CreateObject( "MSXML2.DomDocument" )
36
37
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
37
38
Set objFW = CreateObject( "HNetCfg.FwPolicy2" )
38
39
Set objFWRules = objFW.Rules
@@ -45,12 +46,15 @@ Private Sub Class_Initialize
45
46
strBuiltinDom = GetBuildfileValue( "BuiltinDom" )
46
47
strClusterName = GetBuildfileValue( "ClusterName" )
47
48
strCmdSQL = GetBuildfileValue( "CmdSQL" )
49
+
48
50
strDirSystemDataBackup = GetBuildfileValue( "DirSystemDataBackup" )
49
51
strGroupDBA = GetBuildfileValue( "GroupDBA" )
50
52
strGroupDBANonSA = GetBuildfileValue( "GroupDBANonSA" )
51
53
strGroupMSA = GetBuildfileValue( "GroupMSA" )
52
54
strIsInstallDBA = GetBuildfileValue( "IsInstallDBA" )
53
55
strKeyPassword = GetBuildfileValue( "KeyPassword" )
56
+ strLookupFile = GetBuildfileValue( "LookupFile" )
57
+ strLookupPassword = GetBuildfileValue( "LookupPassword" )
54
58
strLocalAdmin = GetBuildfileValue( "LocalAdmin" )
55
59
strNTAuth = GetBuildfileValue( "NTAuth" )
56
60
strOSVersion = GetBuildfileValue( "OSVersion" )
@@ -76,6 +80,26 @@ Private Sub Class_Initialize
76
80
objADOConn.Open "ADs Provider"
77
81
Set objADOCmd.ActiveConnection = objADOConn
78
82
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
+
79
103
intBuiltinDomLen = Len(strBuiltinDom) + 1
80
104
intNTAuthLen = Len(strNTAuth) + 1
81
105
intServerLen = Len(strServer) + 1
@@ -453,19 +477,27 @@ End Function
453
477
454
478
Function GetCredential(strPassword, strAccount)
455
479
Call DebugLog( "GetCredential: " & strPassword)
456
- Dim strAcctName
480
+ Dim strAcctName, strCredential
457
481
458
- GetCredential = GetBuildfileValue(strPassword)
482
+ strCredential = GetBuildfileValue(strPassword)
459
483
Select Case True
460
- Case LCase(GetCredential ) <> "encrypted "
484
+ Case LCase(strCredential ) <> "lookup "
461
485
' Nothing
462
486
Case strAccount = ""
463
- ' Get credential from Password file
487
+ strCredential = GetXMLParm(objLookup, UCase(strPassword), "lookup" )
464
488
Case Else
465
489
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" )
467
497
End Select
468
498
499
+ GetCredential = strCredential
500
+
469
501
End Function
470
502
471
503
0 commit comments