Downloads
24368.zip

Use ASP and WMI to map your printer locations on a floor map

For users, determining the location of printers in large organizations that use nonintuitive printer-naming conventions is frustrating. The scripting tool I show you in this three-part series uses printer icons and floor maps to display the location of your company's printers and facilitate installation. Users will appreciate how easily they can locate and install printers to their desktops. When users are ready to print, the tool can remind them where the printer is located or show them the new location of a printer that's been moved.

This utility incorporates several technologies, of which two—Windows Management Instrumentation (WMI) and Active Server Pages (ASP)—are key. The tool uses WMI to query printer properties and to obtain the location of each printer. This informations is used to place printer icons for each printer on the floor map. Users can place the cursor on a printer icon to view printer properties that WMI exposes and can click a printer icon to access the Internet Printing Protocol (IPP) interface. The IPP interface lets users see additional printer properties and install printers to their desktop. IPP exposes Windows printers to Web browsers such as Microsoft Internet Explorer (IE) and lets users access printer information and install printers through a URL.

Introducing the Printer Mapping Utility
The printer mapping utility consists of a script, printer images, an HTML page, and a style sheet. To present the Web-based printer mapping interface to users, the script requires Windows 2000 Server, Microsoft IIS, and ASP. The script relies on IPP and WMI running on each print server to display printer properties and allow printer installation from the Web interface. IPP and WMI are installed by default when you install Win2K Server. Table 1 describes each component of the printer mapping utility.

Installation and Configuration
To keep the script as simple as possible, the printer mapping utility runs on each Win2K Server print server. However, in a large network, you can centralize the script files on one Win2K Server machine running IIS and modify the script to connect to the appropriate print server. I've written this utility for Win2K networks; I haven't tested it in mixed environments of Win2K servers and Windows NT 4.0 servers.

In this article, I detail the simple steps you must follow to set up the printer mapping utility on each print server:

  1. Create and configure a Web site and copy the Web script and supporting files to the appropriate subdirectories.
  2. Locate or create company floor maps to display in the Web interface.
  3. Modify the script for your network environment.
  4. Configure your printer location fields to appear on the floor map.

I also summarize how the utility works. Two subsequent articles will show code details for creating the printer mapping utility and explain how to create an administrative interface for managing the utility.

Creating and Configuring the Web Site
IPP operates on computers running Win2K and Internet Information Services (IIS) 5.0. Thus, if you have a print server that's available to all users who will run the utility, consider using that server as the utility's Web server. After selecting an appropriate Web server, complete these steps on the server:

  1. Create a physical directory named PrintersMap. Place it on an NTFS partition and use NTFS permissions to grant Everyone Read access and Administrators Full Control.
  2. Create two subdirectories, Main and Img, within PrintersMap.
  3. Download PrintersMap.zip from the Windows Scripting Solutions Web site (http://www.winscriptingsolutions.com). Put Default.htm, PrintersMap.asp, and StyleSheet.css in the Main subdirectory. Put bwprinter.gif and colorprinter.gif in the Img directory.
  4. Click Start, Programs, Administrative Tools, Internet Services Manager.
  5. In Internet Services Manager (ISM), right-click Default Web Site, New, Virtual Directory. (I'm adding the virtual directory below the Default Web Site node for the sake of simplicity; if you prefer, you can create a new site.)
  6. When the Virtual Directory Creation Wizard appears, click Next.
  7. In the Alias text box, type
  8. PrintersMap

    then click Next.

  9. In the Directory text box, enter the local path to the Main subdirectory of the PrintersMap directory; click Next.
  10. Accept the default Access Permissions settings (the Read and Run scripts options).

Next, configure the virtual directory for Integrated Windows authentication. This procedure secures the script to authenticated Windows users and requires that your users run IE. You can choose Basic Authentication for browsers that don't support Integrated Windows authentication. However, I haven't tested the printer mapping utility in this authentication mode or with browsers other than IE 5.0 and later. To configure authentication in ISM, follow these steps:

  1. In ISM, right-click the virtual directory and select Properties.
  2. Click the Directory Security tab. In the Anonymous access and authentication control section, click Edit.
  3. On the Authentication Methods sheet, clear the Anonymous access option and click OK.
  4. Click OK again to close the PrintersMap Properties sheet.

Locating or Creating Floor Maps
The printer mapping utility relies on floor maps as background images. Often, electronic images accompany blueprints of each floor space. If you can acquire such images, make sure each floor map is uncluttered—for example, remove unattached furniture symbols from the floor map. Then, make the files as small as possible, convert them to monochrome .gif format, and make the floor map dimensions approximately 800 x 600 pixels. Name and save each floor map file in the Img directory you created on your Web server.

You can accomplish the floor map image preparation tasks with a tool such as Microsoft Visio Professional 2002. If you can't obtain floor maps, you'll need to create them. Visio includes a Floor Plan stencil (one of the Building Plan stencils) to get you started. In addition, PrintersMap.zip contains a default floor map named floor6.gif. You can experiment with this floor map if maps of your own space aren't readily available. To maximize the utility's performance, keep your floor maps as simple as possible and try to keep the floor map image files smaller than 100KB. If your users operate their monitors at 640 * 480 resolution, you could make the floor map dimensions smaller than 800 * 600 pixels, but then fitting all the printer images on the floor map might be a challenge.

Customizing the Script
The Default.htm file, which Listing 1 shows, creates a selection form from which users choose a floor and printer. In the Default.htm file, you must change the INPUT tag values and descriptive text in callout A in Listing 1 to correspond to your floor maps and printer locations. For example, to change the radio button that points to print server 1 on the sixth floor so that the button points to print server 10 on the ninth floor, change the first INPUT tag from

<INPUT ID=RADIO type="radio"
  checked id=radio1
  name=FloorName value=Sixth>
  Six (Print Server 1)<br><br>

to

<INPUT ID=RADIO type="radio"
  checked id=radio1
  name=FloorName value=Ninth>
  Nine (Print Server 10)<br><br>

Add or delete INPUT tags as necessary.

Mapping Your Printers
After making sure that the floor maps are being displayed properly and that the script successfully connects to each print server, modify each printer's Location field to map your printers. In my next article, I'll describe how the printer mapping utility connects to your print servers. For now, all you need to understand is how a printer's Location field relates to the printer mapping utility.

The Location field is a standard printer property stored with each printer. If you run the Add Printers Wizard, you'll see the Location field on one of the wizard's pages. You can also access this field from the General tab of an installed printer's Properties page. You must end each printer Location field with the values that specify the location of the printer icon's top left corner on the floor map. You specify this value as the number of pixels from the left side of the browser window and the number of pixels from the top of the browser window. Separate the values with an x and put them in parentheses, as Figure 1 shows. Other text can appear in the Location field, but the ending text must be the properly formatted pixel values. If you specify pixel values manually, you'll probably need to try several pixel values to map the printers to their location on the floor map. After changing the values, you can point or refresh your Web browser to the corresponding floor map to see where the printer icon appears. If this seems like a lot of work, don't despair: The final article of this series will provide a simple administrative interface for placing printers on the map.

How It Works
For the sake of simplicity, the printer mapping utility assumes that each floor has one print server. You can modify the script to change this assumption.

To use the utility, users access the Printers Map floor selection page that Default.htm creates. The default form contains three radio buttons, as Figure 2 shows. Each radio button represents a floor and a print server. When the user selects a floor and clicks Submit, Default.htm loads PrintersMap.asp. The Reset button resets the radio button selection.

PrintersMap.asp displays the appropriate floor map and shows the printer icons in their proper locations. Users can place the cursor on a printer icon to display more information about the printer, as Figure 3 shows.

Stay Tuned for Part 2 and Beyond
You should now have a good idea of what the printer mapping utility does and how to prepare your network environment for it. In the next article, I'll give you the details about PrintersMap.asp and explain how to customize it to your network environment. In the final installment, I'll show you the administrative interface that lets you easily place printers on your floor maps.