Hi All,
I was recently asked if there was a way to mask your connection string in Logi Studio. I thought I'd jot down some notes.My thinking was why not put the connection string in a DLL. That will make it a bit harder for folks to find. Not exactly 128 bit encryption but each step helps. So that means I need a plugin that populates the connection string element in the Settings.xml file BEFORE the Logi report is processed.This should be pretty straight forward.First: There is an excellent plugin example already available on Dev-Net. But it reads from a text file which is still not masked. (Take a look)Step 1: Fire up Visual Studio and create a new Class Library projectStep 2: Add a reference to Logi's DLL.
I then used this code, it's fairly straight forward, if that doesn't makes sense to you, you probably shouldn't be going this route.BTW: Do both of us a favor and check that your connection string is correct by putting it in a normal connection element in the Settings file.
Imports System.Xml
Imports System.Web
Imports System.IO
Public Class LogiPlugin
Public Sub setConnectionString(ByRef rdObjects As rdPlugin.rdServerObjects)
Dim sConnID As String = rdObjects.PluginParameters("ConnID")
Dim xmlSettings As New XmlDocument()
xmlSettings.LoadXml(rdObjects.CurrentDefinition)
'locate your connection element from it's ID (this is passed in from the variable)
Dim eleConn As XmlElement = xmlSettings.SelectSingleNode("//*[@ID='" & sConnID & "']")
Dim sConnection As String = "Server=OneWickedMachine;Database=NorthWind;User Id=sa;Password=ucannothave;"
eleConn.SetAttribute("ConnectionString", sConnection)
rdObjects.CurrentDefinition = xmlSettings.OuterXml
End Sub
End Class
Step 3: Deploy to the fileThere are multiple ways to do this, the most stright forward...but not so formal approach
Step 4: Call Plugin in StudioOpen up Logi Studio and alter the Settings fileAdd a Connection Element, but place "NA" in all the required attributes.Add a Plugin element
Add a Plugin Parameter call and ConnID = NorthWind (or your database)
Step 5: Test it!
You should be good to go from this point.
Suggestion: If you have multiple environments (Dev/QA/Prod), I would add an additional parameter for which connection string to use. This can be done within the vb file and should be pretty straight forward.