Windows authentication for coldfusion 9 datasources

Let’s get into the topic right away.

Simple and straight forward steps on how to setup a Coldfusion 9  datasource with SQL Server 2008 in Windows Authentication mode.

Step 1:-  Go to Programs –>  Microsoft SQL Server 2008 R2 –>Configuration Tools –>SQL Server Configuration Manager.

Step 2: Enable the  TCP/IP protocol under SQL Server Configuration Manager > SQL Server Network Configurations > Protocols for SQLEXPRESS

Step 3: Now double-click the TCP/IP protocol to view the properties. Click on the IP Addresses tab and make sure that the TCP Port is set to 1433 for every IP type.

Step 4: Log in to CF9 Administrator and create a new datasource. While setting up the datasource give the Database name and datasource name the same. Give the server name as “localhost” and the port as your TCP/IP port.

Congratulations. You just  created a datasource that connects to a SQL Database with  Windows Authentication.


CF Admin glitch while Updating Scheduled tasks?

I faced an issue while working with scheduled tasks long back but though of blogging this now. If the interval specified while creating the task was more than 24 hours then we will not be able to update the task from Coldfusion Administrator.

So here we are creating the schedule task through code. Take a note of the interval.

<cfschedule action = “update”
task = “TaskName”
operation = “HTTPRequest”
startDate = “8/7/98”
startTime = “12:25 PM”
interval = “360000”
resolveURL = “Yes”
publish = “Yes”
file = “sample.html”
path = “c:\inetpub\wwwroot\playpen”
requestTimeOut = “600”>

The interval 360000 is like 100 hours.

Now log into the CF Administrator and try to update the task by changing the frequency to One Time.

The Admin throws error message saying that the interval must be less than one day.

The only way i see to update this schedule task is through code.

Is this a glitch of CF admin? I don’t know.

Security update for ColdFusion versions 9, 8.0.1, and 8 and a word of caution

A new security update for ColdFusion versions 9, 8.0.1, and 8 is available now. Important vulnerabilities have been identified for these versions that could lead to cross-site scripting and information disclosure. So an update is highly recommended.

But after taking updates it was reported that the update killed the datasources in the CF admin. After deleting shf8010001.jar from {CF_HOME}/lib/updates/ and restarting the ColdFusion service CF is up and running again. We are still waiting for Adobe to resolve this issue.

Ajax call in ModelGlue without rendering a view

Making an Ajax call is simple and straight forward in ModelGlue.  The concept is simple and is given in detail in Doug’s blog. Read the full tutorial.

In ModelGlue(2) to call the Ajax call we need to have a view. i.e a page needs to be created to act as the view. This is in need if we are using the Ajax call to dynamically load HTML content. The Javascript receives the rendered view and does whatever it was told to do with it. But however there are times when we do not want to have a view rendered for our event(i.e our Ajax call). We simply want to return a value from server(it can even be a mere checking..!!) and assign it to a Javascript variable. For this simple purpose we do not want to create a new page/view.

In order to accomplish this we will have to break the ModelGlue architecture (till now..i couldn’t find any other suitable methods). Anyone who is familiar to ModelGlue architecture will find it easy to understand the below code.

My ModelGlue event:

<event-handler name="test.testFunction">          
          <message name="testFunction" />

Please note that i am not using a view in this event.

And my controller function:-

<cffunction name="testFunction" returnType="any" output="true" >    
<cfargument name="event" type="any" required="true">        

<cfset justtest = 1>

<CFCONTENT TYPE="text" RESET="Yes"><CFOUTPUT>#serializeJSON(justTest)#
<cfset request.modelGlueSuppressDebugging = true />
<cfsetting showdebugoutput="false" /></CFOUTPUT><cfabort>


Here we are converting the justtest variable in JSON format and outputting via cfcontent. Here cfcontent acts as the rendered view and returns justtest in JSON format. Here aborting at the end of controller function can be considered as breaking the ModelGlue archi , but this is one way around to solve the problem.

By the way here is my Ajax call:-

new Ajax.Request(root+'test.testFunction',{
  method: 'post',
  parameters: {param1:paramval},
  onSuccess: function(response){
    var myresult = response.responseText;

I am making use of prototype library for this.

We will get 1 if we alert the responseText call back from the server.

This is only applicable to ModelGlue2. If you are using ModelGlue3 then you would also need to check out how to use fomats in MG3. Thanks Ray Camdon for sharing this link.

Removing viewstate values in ModelGlue

A quick blog post on removing viewstate values in Model Glue…everyone knows  about this, but i didn’t find any useful reference while googling this…also for my reference as well just in case i forget…

Removing a value from the viewstate:

<!--- Here key is the name of the value you want to remove--->

Reading Schedule task details from neo-cron.xml

I found  this code helpful while working with schedule tasks(i’ve been working with it for a while now ;-)).

Schedule tasks that are created in the Coldfusion Administrator can be accessed as structure programatically. This is particularly in need when we need to check through code whether a schedule task has been executed or not. We can also get the details of the existing schedule tasks that are in the Coldfusion administrator.

<!--- Get the scheduler xml file.  It's stored as WDDX in CFroot dir--->
<cffile action="Read"

<!--- Convert the WDDX to CFML - and array of structs --->  
<cfwddx action="WDDX2CFML" input="#TaskXML#" output="GetTasks">

<!--- Dump all the schedule tasks in CF Admin in Struct format. ---> 
<cfdump var="#GetTasks#">

The Scheduler configuration file neo-cron.xml stores all the schedule task details in the CF Admin in xml format. We are simply reading the file and converting the WDDX into an array of structs.

The output should look something like this:


Playing SWF files using cfcontent

Playing swf files using cfcontent is very simple.

The video will not play when we call only the HTML page in which the flash video is embedded. Instead we also need to call the swf file using cfcontent to play the video files.

Playing flash files embedded in HTML can be done by the following code snippet:-

<cfcontent type=”application/x-shockwave-flash;” file=”#FilePathandFileNameOfSWFFile#” deletefile=”no”>

<cfcontent type=”text/html” file=”#FilePathandFileNameOfHTMLFile#” deletefile=”no”>

Previous Older Entries