Scott Stanfield
Vertigo Software, Inc.
September 1998
Summary: Provides the sample files and describes how to install the FMCorp database, components, and Web site. (10 printed pages) Covers system requirements, automatic setup, and manual setup.
Click to copy the Fitch & Mather sample executable file.
Run this file (fmcorp.exe) to setup the Fitch & Mather sample application. This program will also place the source-code files and Microsoft Word versions of all the associated Fitch & Mather articles on your local drive.
The database server requires Microsoft® SQL Server™ 6.5 or 7.0. The Web server must be running Microsoft Internet Information Server (IIS) 4.0. The Web server should also have the Microsoft Windows NT® Option Pack installed with the SMTP (for e-mail) and Site Server Express options (for posting acceptor).
The development machine needs the Microsoft Visual Studio® 6.0 development system (or just Microsoft ® Visual Basic 6.0 and the Microsoft Visual InterDev™ 6.0 development system).
If you want to set up the site automatically, run the setup.vbs script in the Setup folder.
The FMCorp Setup script (setup.vbs) can be broken down into three main parts:
Each of these three areas uncovered some unique problems we encountered while creating an automatic Setup program.
The Setup script automatically creates a database device. The documentation is not clear on how to do this straight from SQL. We used the SQL Trace tool to see how SQL Enterprise Manager does its job and then copied the script for our own use.
The Setup script allows you to skip the device creation process. This is necessary if you are using SQL Server 7.0.
Apart from the database device creation, the entire database schema is contained in a single file called scripts\FMCorpSchema.sql. The Setup program uses ISQL.exe to run this script.
Earlier versions of the Setup program simply copied the Web files to the appropriate Inetpub folder on the Web server. The major drawback to this approach is that it completely bypasses the Microsoft FrontPage® server extensions that allow the project to be browsable from Visual InterDev.
Follow the dialog boxes to create a file-based data source name (DSN) called "FMCorp" that points to your new SQL Server database FMCorp. When finished, you should have access to the Data View tab.
Copying a Web site using this approach is acceptable if you are deploying a site, but not if you are distributing one that will be used as a teaching tool in Visual InterDev.
After many hours of searching for a better way, we figured out how to programmatically create a FrontPage-enabled Web site.
Using a real-time registry-spying tool called Regmon from System Internals, we analyzed the globally unique identifiers (GUIDs) Visual InterDev used when creating a Web site. We found the GUIDs in the registry and tracked them down to a file called vidwoj.dll (in the Program Files\Common Files\Microsoft Shared\Wizards98 folder).
We created a simple Visual Basic test program that referenced the type library in this DLL. After a few hours of trial and error, along with the nifty Object Browser (F2), we figured out how to connect to Web server, enumerate the Web sites, and create new ones.
We converted this code to Visual Basic Scripting Edition (VBScript) by modifying the DIM statements' type declarations and replacing "new" with CreateObject calls. The resulting VBScript code will programmatically create a FrontPage-enabled Web site that is easily browsable from Visual InterDev.
Simply moving the files to Internet Information Server was only part of the challenge. We had to configure individual folder and file permissions programmatically. The special cases include:
The FMCorp Web application needs a data source name in order to connect the Web pages to the database. The Setup program automatically creates the DSN called "FMCorp."
If we were not using Microsoft Transaction Server (MTS) to manage our components, we could simply run regsvr32.exe on FMCorp.dll and be done with it. Instead, we needed to programmatically create a transaction package and add the FMCorp interfaces to that package.
Working from a sample script in the IIS Resource Kit, we were able to open the MTS package collection and add an item called FMCorp. Next, we added the DLL to the new package.
The transaction requirements for each component were also configured in the Setup script.
The Setup script gradually evolved from a much simpler process. Earlier versions ran the schema script through ISQL and copied the files to the Web server.
More features started creeping into the Setup script. After it was too late, we realized we probably should have written a stand-alone program with Visual Basic. We'd have the benefit of a better debugging environment and compiler support.
Testing and debugging Windows Scripting Host (WSH) scripts has come a long way with Visual Studio 6.0. Visual InterDev supports remote debugging of WSH scripts.
After running the automatic Setup, you must create a Visual InterDev 6.0 project based on the new Web site. Open the global.asa file, and follow these instructions:
For the following manual steps, my database server, Web server, and development workstation are all on the same machine, called "Ahi." My SQL Server 6.5 is installed on d:\mssql65, so you might need to change some of the paths to suit your needs.
/* Choose the next suitable virtual device number */
declare @vdevno integer
select @vdevno = min(low / 0x01000000)+1
from master..sysdevices
/* Create a 12 MB database device called FMCorpDevice */
/* Change the physical path PHYSNAME to match your data directory */
DISK INIT NAME = 'FMCorpDevice', PHYSNAME = 'd:\mssql65\data\fmcorp.dat', VDEVNO=@vdevno, SIZE=6144
/* Add a database called FMCorp to the device (4 MB for the log) */
create database FMCorp on FMCorpDevice=8 log on FMCorpDevice=4
(Look in Scripts\dbdevice.sql for this code.)
The preceding commands create a new 12-megabyte (MB) database called "FMCorp." We'll populate the schema in the next step.
Note I would normally execute these commands through the SQL Enterprise graphical user interface (GUI), but this way you can see exactly what is happening behind the scenes.
Reference To learn more about virtual device numbers for database devices and why you calculate them this way, refer to the SQL Server documentation under "DISK INIT" or "sp_helpdevice."
Figure 1. Transaction Server Explorer
Figure 2. Component list
Figure 3. FMCorpTest program
The DSN is hard-coded for my computer, so you'll have to change it by hand. Change the server name "Ahi" to your SQL Server name in the SERVER=Ahi section.
Next, click the Login button. You should see a message similar to the one shown in the Status messages area in Figure 3.
Figure 4. New Project dialog box
Figure 5. FMCorp.inf file
Follow the dialog boxes to create a file-based DSN called "FMCorp" that points to your new SQL Server database FMCorp. When finished, you should have access to the Data View tab.
Using the Internet Service Manager (aka MMC), locate the FMCorp Web project. Right-click the POST folder to display its properties. Change the access permissions to allow Write access. Write access is necessary in order to upload the XML files. Change the application settings to allow Execute privileges. We need Execute in order to run the posting acceptor DLL in this folder. Figure 7 shows the new settings.
Right-click the NTLogin.asp folder to display its properties. Click the File Security tab, and then click the Edit button. Turn off Anonymous access to this file. Only Windows NT-authenticated users will have access to this file. Figure 6 shows the new settings.
Figure 6. NTLogin authentication options
Figure 7. Post folder properties
Although it is faster to install FMCorp using the Setup script, we think it is important to know how to configure and install the site by hand. The Setup script includes valuable information on how to control IIS through the OLE Automation and the metabase.
The script allows fine-grain tuning of permissions on an individual file basis—something you can't do with the MMC.
Scott Stanfield is the president of Vertigo Software, Inc. Vertigo Software is a San Francisco Bay Area-based consulting firm that specializes in the design and development of Windows DNA applications and components. He can be reached at scott@vertigosoftware.com or on the Web at http://www.vertigosoftware.com/.