Program examples compiled using Visual C++ 6.0 compiler on Windows XP Pro machine with Service Pack 2 and some Figure screen snapshots have been taken on Windows 2000 server. The Internet Information Services version is IIS 4.x/5.x/6.x on Windows 2000 Server SP 4 and Windows XP Pro SP 2. The Internet Explorer is 6.x. Topics and sub topics for this tutorial are listed below. A complete information about IIS installation, configuration and testing a Web site is dumped HERE and how to setup FTP server also included HERE. Both Web and FTP servers were done on Windows 2000 Server SP4. Don’t forget to read Tenouk’s small disclaimer.
In Module 32, you used a "homemade" Web based on the Winsock APIs. In this module, you'll learn how to use and extend Microsoft Internet Information Server (IIS), which is bundled with Windows Server. IIS is actually three separate servers, one for HTTP (for the World Wide Web), one for FTP, and one for gopher. This module tells you how to write HTTP server extensions using the Microsoft IIS application programming interface (ISAPI) that is part of Microsoft ActiveX technology. You'll examine two kinds of extensions: an ISAPI server extension and an ISAPI filter, both of which are DLLs. An ISAPI server extension can perform Internet business transactions such as order entry. An ISAPI filter intercepts data traveling to and from the server and thus can perform specialized logging and other tasks.
The exercises in this module assume that you have Windows Server and IIS. If you are running Windows Workstation, you can use Peer Web Services, which supports fewer connections and doesn't allow virtual servers. If you are running Microsoft Windows 95 or Windows 98, you can use Personal Web Server, which is packaged with Microsoft FrontPage. Internet Information Server, Peer Web Services, and Personal Web Server can all use ISAPI extension DLLs. See your server's documentation for operating details.
Microsoft IIS is a high-performance Internet/intranet server that takes advantage of Windows NT features such as I/O completion ports, the Win32 function TransmitFile(), file-handle caching and CPU scaling for threads.
Installing and Controlling IIS
When you install Windows Server, you are given the option of installing IIS. If you selected IIS at setup, the server will be running whenever Windows NT is running. IIS is a special kind of Win32 program called a service (actually three services, WWW, HTTP, and gopher, in one program called inetinfo.exe), which won't appear in the taskbar. You can control IIS from the Services icon in the Control Panel or through the Administrative Tools menu, but you'll probably want to use the Internet Service Manager program instead.
Running Internet Service Manager
You can run Internet Service Manager from the Administrative Tools menu that's accessible on the Start Program menu.
Figure 1: Internet Service Manager menu on Windows 2000 Server.
You can also run an HTML-based version of Internet Service Manager remotely from a browser. That version allows you to change service parameters, but it won't let you turn services on and off. Figure 2 shows the Microsoft Internet Service Manager screen with the World Wide Web (WWW) and FTP are running. You can select a service by clicking on its icon at the left. The triangle and square buttons on the toolbar of the screen allow you to turn the selected service on or off.
Figure 2: The Microsoft Internet Service Manager screen.
After you double-click on the WWW service icon of the Microsoft Internet Service Manager screen or using the context menu as shown below, you'll see a property sheet.
Figure 3: Invoking the web server properties pages through the context menu.
The Properties page lets you configure many aspects of IIS. When a client browser requests a file, the server impersonates a local user for the duration of the request and that user name determines which files the client can access. Which local user does the server impersonate? Most often, it's the one you see in the Username field, shown in Figure 4 and can be accessed by selecting the Directory Security tab and click the Edit button.
Figure 4: The WWW Service Properties screen.
Click the Edit button.
Figure 5: Web authentication method, an anonymous access.
Figure 6: Anonymous account used by web user to access the web server (web site).
Most Web page visitors don't supply a user name and password, so they are considered anonymous users. Those users have the same rights they would have if they had logged on to your server locally as IUSR_MYMACHINENAME. That means that IUSR_MYMACHINENAME must appear in the list of users that is displayed when you run (from the Administrative Tools menu) Active directory Users and Computers, and the passwords must match. The IIS Setup program normally defines this anonymous user for you. You can define your own WWW anonymous user name, but you must be sure that the entry on the Properties page matches the entry in the computer's (or Windows NT domain's) user list. Note also the Authenticated access options. For the time being, stick to the Anonymous Access option only, which means that all Web users are logged on as IUSR_MYMACHINENAME. Later in this module, we'll explain Windows NT Challenge/Response.
Remember SlowSoft's Web site from Module 32? If you requested the URL http://slowsoft.com/newproducts.html, the newproducts.html file would be displayed from the slowsoft.com home directory. Each server needs a home directory, even if that directory contains only subdirectories. The home directory does not need to be the server computer's root directory, however. As shown in Figure 7, the default WWW home directory is really c:\Inetpub\wwwroot, so clients read the disk file \wwwroot\newproducts.html. The content of the web site also can be on the shared directory/drive located on other server(s) or the web user can be redirected to other web addresses (URLs).
Figure 7: The wwwroot, default WWW home directory screen.
If you select the Directory Browsing option of the Directories page on the service property screen, browser clients can see a hypertext list of files in the server's directory instead. Your server could get by with a home directory only, but the IIS virtual directory feature might be useful. The virtual directory can be created using New Virtual Directory context menu shown below. It is used to map the IIS directory to the real physical directory.
Figure 8: Creating virtual directory that can be used by web server to map to the real, physical directory.
If your computer was configured for multiple IP addresses, IIS would allow you to define virtual Web servers. Each virtual server would have its own home directory (and virtual directories) attached to a specified IP address, making it appear as though you had several server computers. Unfortunately, the IIS Web server listens on all the computer's IP addresses, so you can't run IIS simultaneously with the MYEX34A server with both listening on port 80. As described in Module 34, browsers can issue a blind request. As Figure 9 shows, Internet Service Manager lets you specify the file that a blind request selects, usually Default.htm. From Figure 9, Default.htm will be used, if not available/found, the second document, Default.asp will be used and so on. If none of the default document available, browser returns a typical error page not found. However if the default document option is disabled, the start page conventionally named index.html, if available, will be used automatically.
Figure 9: Default.htm, the default document of the web site. You can add new or remove those default documents.
IIS is capable of making log entries for all connections. You control logging from the Internet Service Manager's Logging property page. You can specify text log files, or you can specify logging to an SQL/ODBC database. Log entries consist of date, time, client IP address, file requested, query string, and so forth. You can access the logging settings by selecting the Enable Logging and clicking the Properties button as shown below.
Figure 10: Web server with logging enabled.
Figure 11: General settings for web server logging.
Figure 12: Advanced settings for web server logging.
It's easy to test IIS with a browser or with any of the MYEX34A clients. Just make sure that IIS is running and that the MYEX34A server is not running. The default IIS home directory is c:\Inetpub\wwwroot, and some HTML files are 'installed' there. If you're running a single machine, you can use the localhost (or 127.0.0.1) host name. For a network, use a name from the Hosts file. If you can't access the server from a remote machine, run ping to make sure the network is configured correctly. Don't try to build and run ISAPI DLLs until you have successfully tested IIS on your computer. The complete steps to configure IIS and test your web site using IIS 4.x/5.x on Windows 2000 Server are dumped at Setting up IIS web server.
Continue on next Module...
Further reading and digging:
DCOM at MSDN.
COM+ at MSDN.
COM at MSDN.
Win32 process, thread and synchronization story can be found starting from Module R.
MSDN MFC 9.0 class library online documentation - latest version.