views:

311

answers:

1

Hey all,

Anyone pretty familiar with FTP 7.5 extensibility in IIS know what I might be doing wrong?

I am having serious trouble getting an implementation of IFtpLogProvider to work correctly for custom logging. All I want to do is log failures beyond a static threshold to the event log, and have garbage collection every so often. I've tried working with a generic dictionary and the provider with no luck, and now even this simple bit of code I can't get working. The provider is not even creating the event log in the code stub below (or using it if I create it beforehand). So now I am deeply confused.

I follow the instructions to register the assembly after it is signed from within VS and I can confirm that it is added to the GAC. Adding it to IIS 7.5 via the Register Custom Providers option seems to be fine, too.

Any help with specific suggestions would be greatly appreciated, as even with the excellent set of tutorials by Robert McMurray I am still having these issues. I am running this on a 2008 R2 box, by the way, using the interface for managed code.

Stub below:

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration.Provider;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Diagnostics.Eventing;
using System.Text;
using Microsoft.Web.FtpServer;
using System.IO;

public class test: BaseProvider, IFtpLogProvider
{

    void IFtpLogProvider.Log(FtpLogEntry loggingParameters)
    {
        if (!EventLog.SourceExists("TEST"))
        {
            EventLog.CreateEventSource("TEST", "TEST");
        }

        // Just trying to get anything into this log, like a list of
        // USER attempts or something
        EventLog.WriteEntry("TEST", loggingParameters.Command);

    }

    // Mark an IP address for banning.
    private void BanAddress(string ipAddress)
    {
        EventLog.WriteEntry("TEST", ipAddress, EventLogEntryType.Warning, 9010);
    }
}
A: 

I had the following issues:

1) I had an incorrect class name in my registration of this assembly in IIS:

FtpLogging.FtpLogDemo,FtpLoggingDemo,version=1.0.0.0,Culture=neutral,PublicKeyToken=

2) I did not closely follow Robert's advice when registering the assembly. I left the checkbox checked, and this kept it as an authentication provider, which this code sample is not. I instead left basic auth enabled, disabled anonymous auth (in my case), and unchecked the box mentioned in the tutorial -- 'Clear the FtpLoggingDemo check box in the providers list.'

3) I was not using AppCmd (or modifying the appropriate section in applicationHost.config directly) to update the custom providers section in applicationHost.config

<customFeatures>
    <providers>
        <add name="FtpLoggingDemo" enabled="true" />
    </providers>
</customFeatures>

Doing these three things fixed the issue.

asteroid