Encrypted connectionString(s)

Posts   
 
    
ts_mjolner
User
Posts: 13
Joined: 28-Sep-2007
# Posted on: 16-Nov-2007 13:28:13   

Hi

I'm working on a project where we use LLBLGen Pro 2.5.

We have now received a requirement from our customer that states that the connectionstring should be encrypted.

As far as I can see I have no way of controlling that when using LLBLGen?

The question is if LLBLGen allready supports it? How does the ORMSupportClasses get the connectionstring when the LLBL project calls:

ConfigFileHelper.ReadConnectionStringFromConfig( DataAccessAdapter.ConnectionStringKeyName)

?

Does it use:

ConfigurationManager.ConnectionStrings[connStringName].ConnectionString

?

If it uses that then all is good, because .NET decrypts the information automatically then smile

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 16-Nov-2007 15:45:55   

Here is the code of the ReadConnectionStringFromConfig() method.

#if !CF
        /// <summary>
        /// Reads the value of the setting with the key CatalogNameUsageSetting from the *.config file and stores that value as the
        /// active setting for catalogNameUsageSetting for this instance, IF specified. If specified, a key with the name CatalogNameToUse is
        /// expected as well.
        /// </summary>
        /// <param name="keyName">Name of the key.</param>
        /// <returns>the connection string, if found, otherwise empty string</returns>
        /// <remarks>First tries to read from the connectionstrings settings (new in .NET 2.0). If not found, it will try to read it from the appSettings tag</remarks>
        public static string ReadConnectionStringFromConfig(string keyName)
        {
#if MONO
            // read it from the appsettings
            string toReturn = ConfigurationSettings.AppSettings[keyName];
            if(toReturn == null)
            {
              toReturn = string.Empty;
            }
            return toReturn;            
#else
            string connectionString = string.Empty;
            ConnectionStringSettings connectionStringData = ConfigurationManager.ConnectionStrings[keyName];
            if(connectionStringData != null)
            {
                connectionString = connectionStringData.ConnectionString;
            }
            if(!String.IsNullOrEmpty(connectionString))
            {
                // found it
                return connectionString;
            }

            // read it from the appsettings
            string toReturn = ConfigurationManager.AppSettings[keyName];
            if(toReturn == null)
            {
                toReturn = string.Empty;
            }
            return toReturn;
#endif // MONO
        }
#endif // !CF
    }

Which uses ConfigurationManager.ConnectionStrings[keyName] first and if nothing is found it uses the AppSettings.

Also here are couple of threads almost discussing the same issue: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=5428 http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=11035