Viewing current FTP7 sessions

Posted: Jun 13, 2007  2 comments  

Average Rating

Tags
FTP
FTP7
sample
script

Share this Post

FTP7 Beta administrative tool doesn't include information about currently executing Ftp sessions. The FTP7 runtime session information is exposed through the IIS7 config API extensibility but the information

I know there are administators out there wondering how to access this useful information with new FTP7 server. So here is a simple jscript function that will dump all the active sessions for the given site name. I recommend running with the cscript.exe engine to dump the information to the command line and to avoid window pop-ups

 function DumpFtpSessions( siteName )
{
    var adminManager = WScript.CreateObject(
                            "Microsoft.ApplicationHost.WritableAdminManager" );
    var sitesElement = adminManager.GetAdminSection(
                                        "system.applicationHost/sites",
                                        "MACHINE/WEBROOT/APPHOST" );

    var myFtpSiteElement;

    var n,k;
        
    //
    // check if site exists
    //
    for ( var i = 0; i < sitesElement .Collection.Count; i++ )
    {
        var siteElement = sitesElement.Collection.Item( i );
       
        if ( siteElement.Properties.Item( "name" ).Value == siteName )
        {
            myFtpSiteElement = siteElement;
            break;
        }
    }

    if ( myFtpSiteElement == null )
    {
        // site doesn't exist; report an error
        WScript.Echo( "Site "+ siteName + " was not found" );
        return;
    }

    WScript.Echo( "Active session for site " + siteName + "." );

    //
    // get hold of the configuration element with runtime details of current
    // ftp sessions
    //
    var ftpServer = myFtpSiteElement.ChildElements.Item("ftpServer")
    var ftpSessions = ftpServer.ChildElements.Item( "sessions" );

    for ( n = 0;
          n < ftpSessions.Collection.Count;
          n++ )
    {
        WScript.Echo( "-------Session " + n + "--------" );
        var ftpSession = ftpSessions.Collection.Item( n );

        for ( k = 0;
               k < ftpSession.Properties.Count;
               k++ )
        {
            var Property = ftpSession.Properties.Item( k );

            WScript.Echo( Property.Name +": " + Property.Value );
        }
    }
}

Submit a Comment

  • Plain text is accepted.
  • URLs starting with http:// are converted to links.