Scott Forsyth's Blog

Postings on IIS, ASP.NET, SQL Server, Webfarms and general system admin.

.

  • Scott Forsyth

Hosting Needs

Training and Dev Labs

February 2012 - Posts

IIS FTP Troubleshooting-Week 48

You can find this week’s video here.

This lesson covers ways to troubleshoot IIS FTP. When it works, it works well, but if you run into issues getting an FTP account working it can sometimes be difficult to resolve. This video will help you understand some helpful tricks and it will walk you through ways to isolate and resolve the issue.

Over the last five weeks we’ve been looking at IIS FTP. See the list below to jump to a specific FTP topic.  This week we explore some troubleshooting techniques and review the following FTP connectivity stack.

  • DNS Resolution/Network Connectivity
  • Firewall Access (Passive/Active / Secure?)
  • IIS Bindings
  • Authentication
  • Authorization
  • Isolation Mode / File paths
  • NTFS Permissions

There were two external resources which I referenced. They are:

This is now week 48 of a 52 week series for the web pro and it is the final of a 5-week mini-series on IIS FTP. The five weeks include:

You can find this week’s video here.

Posted: Feb 21 2012, 10:58 AM by OWScott | with no comments
Filed under: , , ,
FTP Firewall Settings, Active vs. Passive, and FTPS Explicit vs. Implicit-Week 47

You can find this week’s video here.

Have you ever wondered what FTP Active mode or Passive mode means? Do you have a good understanding of the FTP data channel or control channel? It can be difficult to fully understand FTP, which firewall ports to enable, and how to navigate the two communication channels. This lesson will hopefully clear up these questions and more.

This week’s video lesson takes a deep dive into FTP Active vs. Passive modes. As part of this you’ll get a chance to see the various modes in action, see what the traffic looks like in Wireshark, see exact firewall rules, learn about stateful FTP, find out about Explicit FTPS and Implicit FTPS, and learn about the FTP data channel and control channels.

This week's video lesson is the 4th of a 5-week mini-series on IIS FTP. The five weeks include:

  • Week 1: IIS FTP Basics
  • Week 2: IIS FTP and IIS Manager Users
  • Week 3: IIS FTP and User Isolation
  • Week 4: IIS FTP Firewall settings, Active vs. Passive
  • Week 5: IIS FTP Troubleshooting plus FTP Host Headers

This is now week 47 of a 52 week series for the web pro, and the 4th of a 5 week mini-series on IIS FTP. You can view past and future weeks here: http://dotnetslackers.com/projects/LearnIIS7/

You can find this week’s video here.

Flush IIS HTTP and FTP Logs to Disk

Today I wanted to find a way to flush the IIS FTP logs on-demand.  The logs for IIS FTP flush to disk every 6 minutes, and the HTTP logs every 1 minute (or 64kb).  This can make troubleshooting difficult when you don’t receive immediate access to the latest log data.

After looking everywhere I could think of, from search engine searches to perusing through the IIS schema files, I figured I had better go to the source and ask Robert McMurray.

Sure enough, Robert had the answer and even wrote a blog post in response to my question with code examples for four scripting/programming languages (C#, VB.NET, JavaScript, VbScript).

There is not a netsh or appcmd solution though, so the scripting or programming options are the way to do it.  Actually, you can also flush the logs by restarting the Microsoft FTP Service (ftpsvc) but, as you would assume, it will impact currently active FTP sessions.

This blog post serves three purposes. 

  1. It’s a reference pointing to Robert’s examples
  2. I’ll include how to do the same for the HTTP logs
  3. I’ll provide a PowerShell example which I based on Robert’s examples

1. The reference is mentioned above already, but to give me something useful to write in this paragraph, I’ll include it again. Programmatically Flushing FTP Logs.

2. For HTTP there is a method to flush the logs using netsh.

netsh http flush logbuffer

This will immediately flush the HTTP logs for all sites.

3. The FTP logs can be done from PowerShell too.  Here’s a script which is the PowerShell equivalent of Robert’s examples.  Just update $siteName, or pass it as a parameter to the script.

Param($siteName = "Default Web Site") 
 
#Get MWA ServerManager
[System.Reflection.Assembly]::LoadFrom( "C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll" ) | Out-Null
$serverManager = new-object Microsoft.Web.Administration.ServerManager 
 
$config = $serverManager.GetApplicationHostConfiguration()
 
#Get Sites Collection
$sitesSection = $config.GetSection("system.applicationHost/sites")
$sitesCollection = $sitesSection.GetCollection() 
 
#Find Site
foreach ($item in $sitesCollection){ 
 
    if ($item.Attributes.Item("Name").Value -eq $siteName){
        $site = $item
    }
}
#Validation
if ($site -eq $null) { 
    Write-Host "Site '$siteName' not found"
    return
}
 
#Flush the Logs
$ftpServer = $site.ChildElements.Item("ftpServer")
 
if (!($ftpServer.ChildElements.Count)){
    Write-Host "Site '$siteName' does not have FTP bindings set"
    return
}
 
$ftpServer.Methods.Item("FlushLog").CreateInstance().Execute()

I hope one of these programming/scripting options come in handy for times when you want immediate access to the latest FTP log data.

More Posts