O'Reilly logo

Practical Internet Groupware by Jon Udell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Pass-Through ISAPI Authentication Filter

Web servers process requests in phases—user authentication, HTTP header processing, URL-to-filename mapping. Each phase creates the opportunity for a server extension—which can be a Netscape Server API (NSAPI) plug-in, or an Apache module, or an ISAPI filter—to alter the server’s behavior in some useful way. In this case we need to hook into the user authentication phase. Microsoft’sVisual C++ compiler makes that very easy to do, because it includes a wizard that knows about the phases of IIS request processing and can generate the framework for a filter that deals with one or more of these phases. To create a custom authentication handler, start the MS Developer Studio and do File New Projects ISAPI Extension Wizard. Check the Generate a Filter Object box, uncheck Generate a Server Extension Object, and then complete the ensuing dialog box, as shown in Figure 12.1.

Generating the framework for an ISAPI filter

Figure 12-1. Generating the framework for an ISAPI filter

Example 12.2 shows our completed authentication filter. It’s mostly boilerplate code written by the wizard. The four lines in the body of the CMod_authFilter::onAuthentication( ) method are the only human contribution to this filter.

Example 12-2. A Pass-Through Isapi Authentication Filter

// MOD_AUTH.CPP - Implementation file for your Internet Server // mod_auth Filter #include "stdafx.h" #include "mod_auth.h" CWinApp ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required