Database: decrypt connection string in Get_ConnectionStringforID
This commit is contained in:
@@ -141,12 +141,17 @@ Public Class MSSQLServer
|
|||||||
End Select
|
End Select
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Public Function GetConnectionStringForId(pConnectionId As Integer) As String
|
||||||
|
Return Get_ConnectionStringforID(pConnectionId)
|
||||||
|
End Function
|
||||||
|
|
||||||
Public Function Get_ConnectionStringforID(pConnectionId As Integer) As String
|
Public Function Get_ConnectionStringforID(pConnectionId As Integer) As String
|
||||||
Dim connectionString As String = ""
|
Dim oConnectionString As String = ""
|
||||||
|
|
||||||
Try
|
Try
|
||||||
Dim oDTConnection As DataTable = GetDatatable($"SELECT * FROM TBDD_CONNECTION WHERE GUID = {pConnectionId}")
|
Dim oTable As DataTable = GetDatatable($"SELECT * FROM TBDD_CONNECTION WHERE GUID = {pConnectionId}")
|
||||||
If oDTConnection.Rows.Count = 1 Then
|
If oTable.Rows.Count = 1 Then
|
||||||
Dim oRow As DataRow = oDTConnection.Rows(0)
|
Dim oRow As DataRow = oTable.Rows(0)
|
||||||
Dim oProvider = oRow.Item("SQL_PROVIDER").ToString.ToUpper
|
Dim oProvider = oRow.Item("SQL_PROVIDER").ToString.ToUpper
|
||||||
Dim oServer = oRow.Item("SERVER")
|
Dim oServer = oRow.Item("SERVER")
|
||||||
Dim oDatabase = oRow.Item("DATENBANK")
|
Dim oDatabase = oRow.Item("DATENBANK")
|
||||||
@@ -156,28 +161,33 @@ Public Class MSSQLServer
|
|||||||
Select Case oProvider
|
Select Case oProvider
|
||||||
Case "MS-SQL"
|
Case "MS-SQL"
|
||||||
If oUser = "WINAUTH" Then
|
If oUser = "WINAUTH" Then
|
||||||
connectionString = $"Server={oServer};Database={oDatabase};Trusted_Connection=True;"
|
oConnectionString = $"Server={oServer};Database={oDatabase};Trusted_Connection=True;"
|
||||||
Else
|
Else
|
||||||
connectionString = $"Server={oServer};Database={oDatabase};User Id={oUser};Password={oPassword};"
|
oConnectionString = $"Server={oServer};Database={oDatabase};User Id={oUser};Password={oPassword};"
|
||||||
End If
|
End If
|
||||||
Case "Oracle"
|
|
||||||
|
Case "ORACLE"
|
||||||
If oRow.Item("BEMERKUNG").ToString.Contains("without tnsnames") Then
|
If oRow.Item("BEMERKUNG").ToString.Contains("without tnsnames") Then
|
||||||
connectionString = $"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={oServer})(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME={oDatabase})));User Id={oUser};Password={oPassword};"
|
oConnectionString = $"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={oServer})(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME={oDatabase})));User Id={oUser};Password={oPassword};"
|
||||||
Else
|
Else
|
||||||
connectionString = $"Data Source={oServer};Persist Security Info=True;User Id={oUser};Password={oPassword};Unicode=True"
|
oConnectionString = $"Data Source={oServer};Persist Security Info=True;User Id={oUser};Password={oPassword};Unicode=True"
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Case Else
|
Case Else
|
||||||
_Logger.Warn("Provider {0} nicht unterstützt!", oProvider)
|
_Logger.Warn("Provider {0} nicht unterstützt!", oProvider)
|
||||||
|
|
||||||
End Select
|
End Select
|
||||||
|
|
||||||
Else
|
Else
|
||||||
_Logger.Info("No entry for Connection-ID: " & pConnectionId.ToString)
|
_Logger.Info("No entry for Connection-ID: " & pConnectionId.ToString)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_Logger.Error(ex)
|
_Logger.Error(ex)
|
||||||
_Logger.Info("Error in bei Get_ConnectionStringforID")
|
_Logger.Info("Error in bei Get_ConnectionStringforID")
|
||||||
End Try
|
End Try
|
||||||
Return connectionString
|
|
||||||
|
Return DecryptConnectionString(oConnectionString)
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
<DebuggerStepThrough()>
|
<DebuggerStepThrough()>
|
||||||
|
|||||||
Reference in New Issue
Block a user