debuggingcoldfusionjrun

How to detect Line Debugging in on & the debugger is running?


We have a ColdFusion 8 application running in JRun4 on Windows Server 2003.

How do we detect (& display) whether the debugger is running with Allow Line Debugging enabled in CF Administrator. After detecting, we want to display a warning on the application that the debugger is running.


Solution

  • You should be able to use the ColdFusion Administrator API for this. Of course you will need the security/permissions in order to use this. If you are using sandbox security, enable access to the cf_web_root/CFIDE/adminapi directory to use the Administrator API. Basically the Administrator API gives you programmatic access to most of the ColdFusion Administrator settings.

    From the documentation:

    You can use the Administrator API to perform most ColdFusion Administrator tasks programmatically. The Administrator API consists of a set of ColdFusion components (CFCs) that contain methods you call to perform Administrator tasks.

    The CFC for managing the debug settings is debugging.cfc.

    Here is some pseudo code (this has not been tested):

    <cfscript> 
    
    // Instantiate the administrator.cfc 
    adminObj = createObject("component","cfide.adminapi.administrator");
    
    // Call the administrator.cfc login method, passing the ColdFusion Administrator password
    adminObj.login("#password#","#username#");
    
    // Instantiate the debugging CFC
    debugObj = createObject("component","cfide.adminapi.debugging");
    
    // Call the desired CFC method
    if (debugObj.isLineDebuggerEnabled()) {
    
        if (debugObj.isLineDebuggerRunning()) {
    
            // Stop line debugger
            debugObj.stopLineDebugger();
        }
    
        // Disable the line debugger
        debugObj.setLineDebuggerEnabled(enabled="false");
    }
    
    </cfscript>
    

    That should get you started. Here is some documentation on the debugging.cfc and it's methods.

    Manages debug settings.
    
    hierarchy:  WEB-INF.cftags.component
                CFIDE.adminapi.base
                CFIDE.adminapi.debugging
    path:   {web-root}\CFIDE\adminapi\debugging.cfc
    serializable:   Yes
    properties: 
    methods:  addDebugEvent,
              deleteIP,
              getCurrentIP,
              getDebugProperty,
              getDebugRecordset,
              getIPList,
              getLineDebuggerPort,
              getLogProperty,
              getMaxDebuggingSessions,
              isLineDebuggerEnabled,
              isLineDebuggerRunning,
              restartLineDebugger,
              setDebugProperty,
              setIP,
              setLineDebuggerEnabled,
              setLineDebuggerPort,
              setLogProperty,
              setMaxDebuggingSessions,
              startLineDebugger,
              stopLineDebugger,
              validateIP*
    inherited methods:  dump,
                        getEdition,
                        getInstallType,
                        getJRunRootDir,
                        isAdminUser,
                        RDSInvoker,
                        setJrunSN