How to Use Native Code (C++) to Create a Simple FTP Home Directory Provider

Microsoft has created a new FTP service that has been completely rewritten for Windows Server® 2008. This new FTP service incorporates many new features that enable Web authors to publish content more easily than before, and offers Web administrators more security and deployment options.

The new FTP 7.5 service supports extensibility that lets you extend the built-in functionality that is included with the FTP service. More specifically, FTP 7.5 supports the creation of your own authentication and authorization providers. You can also create providers for custom FTP logging and for determining the home directory information for your FTP users.

This walkthrough will lead you through the steps to use native code to create a simple FTP home directory provider.

Prerequisites

The following items are required to complete the procedures in this article:

1. IIS 7.0 or above must be installed on your Windows Server 2008 server, and the Internet Information Services (IIS) Manager must also be installed.

The new FTP 7.5 service must be installed. You can download and install the FTP 7.5 service from the http://www.iis.net/ web site using one of the following links:

Note: If you use an earlier version of Visual Studio, some of the steps in this walkthrough may not be correct.

Note: If you plan to develop custom FTP providers for computers that use a 64-bit version of Windows, you will have to install the 64-bit tools and compilers for Visual Studio. You can find additional information about 64-bit development in the Installing Visual Studio 64-bit Components topic on the Microsoft MSDN Web site.

A home directory for each user must be created; the code sample uses C:\Ftpusers\%UserDomain%\%UserName%, but you could change that as necessary.

Step 1: Set up the Project Environment

In this step, you will create a project in Visual Studio 2008 for the demo provider.

Open Microsoft Visual Studio 2008.

Click the File menu, then New, then Project.

In the New Project dialog box:

Choose Visual C++ as the project type.

Choose ATL Project as the template.

Type FtpHomeDirectoryDemo as the name of the project.

Click OK.

When the ATL Project Wizard dialog appears:

Click Next.

Ensure that only Dynamic-link library (DLL) is checked.

Click Finish.

When the project opens, add an ATL Class to the project:

Click Project, and then click Add Class.

Choose ATL Simple Object as the template.

Click Add.

When the ATL Simple Object Wizard appears:

Enter "FtpHomeDirDemo" for the short name and accept the defaults for the other values.

Click Next.

Choose the following options:

Choose Apartment for the Threading model. (Note: This can be customized depending on your application's needs.)

Choose No for Aggregation. (Note: This can be customized depending on your application's needs.)

For the Location, enter the full path of the FTP extensibility type library. For example:

C:\Windows\System32\inetsrv\ftpext.tlb

Note: If you are developing on a 64-bit computer, you should copy the FTP extensibility type library to the following 32-bit path and use that location. For example:

C:\Windows\SysWOW64\inetsrv\ftpext.tlb

Choose the following interface to implement:

IFtpHomeDirectoryProvider

Click Finish.

Configure the project so that the DLL will not be registered automatically:

Click Project, and then click FtpHomeDirectoryDemoProperties.

Expand Configuration Properties, and then click Linker.

Select Register Output, and select No from the drop-down menu.

Click OK.

Optional: If you are developing your custom provider on a 32-bit version of Windows, you can optionally add a custom build event to automatically deploy and register the DLL on your development computer. (Note: These steps will not work on a 64-bit version of Windows.) To add the custom build event, follow these steps:

By Robert McMurray

Robert McMurray is a Technical Writer at Microsoft. Robert has been with Microsoft for 17 years, where he worked in Technical Support for IIS 1.0 through IIS 5.0, and as a Technical Writer for IIS 6.0 and IIS 7.0. Robert was a Program Manager on the IIS Product Team for IIS 7.0, IIS 7.5, and IIS 8.0, where he was responsible for IIS Express, URL Rewrite, and the Web Publishing technologies (FTP, WebDAV, FPSE).