English 中文(简体)
IIS FTP 7.5 Extensibility (IFtpLogProvider and logging FTP failures to the event log)
原标题:

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);
    }
}
最佳回答

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.

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签