
Posted by Lawrence
For security reasons, before you take your site live you should change your DSN to something unique to your site and not easy to guess. Here are a couple quick and easy ways to do it.
For security reasons you need to be absolutely sure that your application’s DSN is unique. This is especially true if you are using a commercial application or extension.
To change the DSN in your application from the default name to a new one you use Dreamweaver MX's very powerful global search and replace. Here are the steps.
There you go. You are all safe and secure. Doing it this way only take about 5 minutes as opposed to trying to do it page by page. Which would drive you nuts in short order. Now, if you are using CFMX, there’s a new feature that makes this even easier!
First open you Application.cfm file and set a DSN variable name. We will declare it in the “request” scope so it will be available to all files, even nested Custom Tags. Do this like so…
<cfset request.MyDSN = “YourActualDSN”>
Now in DWMX go to your “Bindings” panel and click the + and select “Data Source Name Variable” from the dropdown menu. In the “Variable Name” field enter the variable name you created in your Application.cfm file (request.MyDSN). Finally, Select the actual Data Source from the dropdown.
From now on you will choose the DSN Variable when you create a Record set and your DSN will look like this in your cfquery…
<cfquery datasource=<cfoutput>#request.MyDSN#</cfoutput>
Now all of your DSNs will be called dynamically and you need only change the DSN in your Application.cfm page and it will be changed site wide! Is that cool or what!