Novell Home

AppNote: Location-Based Printing for Metaframe Services

Novell Cool Solutions: AppNote
By Eric Belcher

Digg This - Slashdot This

Posted: 8 Dec 2005
 

Eric Belcher
Technology Services Manager
Anglican Church Grammar School (ACGS)
East Brisbane – QLD - Australia

Table of Contents

Introduction
The Problem
The Solution
Resources
Limitations
Environment
Iprint Installation
Overview of iPrint
Installation of the iPrint Agent
iPrint Implementation
iPrint Configuration
Environment Setup
Silent Operation
SEVICA.INI Configuration
Device Naming Convention
Installation Steps
Appendix 1 – iPrntMFSelect.vbs
Appendix 2 – NAL Application AXT File
AXT_FILE 3.1
XML File

Introduction

This document details the installation of location-based printing facilities for Citrix Metaframe using Novell iPrint. The solution is based upon the ideas of David Shepherd, Novell Consulting UK in a document published on the Novell web site. Components of this text are taken from his document; Using Novell Solutions to Provide Integration with Citrix Products. The solution has been adapted by Eric Belcher of Anglican Church Grammar School to suit the Novell integrated Citrix Metaframe (MF) solution in place.

The Problem

The ACGS Metaframe solution is a small component of a much larger network system that operates in two modes. The first has multiple users using a MF thin client device which are in fixed locations and a single person accessing MF through the a portal solution from multiple locations. The automatic assignment of default printers for the fixed location devices has proved unachievable till now. Users to this point have had to manually select their default printer from a list of server installed printers. Failure to do so has caused printing to appear at various and unrelated areas of the campus.

The Solution

Using a third party utility, session information regarding the the fixed location devices can be extracted. ICAClientInfo reads the session information provided by the Citrix APIs and outputs a batch file to stdout which will set environment variables containing the values acquired from the APIs. As all devices at ACGS are named for inventory and management purposes, the device name is extracted and used to allocate and location associated default printer for the user.

Resources

Limitations

As documented, this solutions does not solve the following issues:
  • Only one printer is installed per location. A second printer cannot be automatically.
  • The removal of all server based printers impacts on programs that require operate. At ACGS Portal users are not allocated a printer.
  • A maximum list of 30 locations only is accounted for in the solution.

Environment

The ACGS environment is a highly integrated and locked down system. The backbone of the Network uses Novell NetWare 6.5 with eDir as the central directory service. ZENworks for Desktops 6.5/7.0 is deployed to manage desktops, deploy applications, deliver application access points via NAL on both desktops and MF sessions and to configure Windows servers including the MF servers.

AGCS employs Citrix Metaframe Presentation 4.0 on Windows 2003 based servers. Appsense is also deployed to manage and limit available applications, CPU and memory optimization. Access to Drive C is removed for users except for Read/Execute.

While this environment provides high levels of stability in a volatile and hostile environment, it does add a number of complexities to the implementation of this solution. These will be highlighted in bolded text as they may not apply at other sites and are not part of the core solution presented here. [Sample Bolded Text]

Iprint Installation

Overview of iPrint

With the introduction of iPrint, the printing functionality has been abstracted from the Novell Client into its own separately installed component. Although the Novell Client still provides support for Novell Distributed Print Services, the iPrint client can now be installed without any Novell Client being present on the machine and yet provide printing functionality.

Installation of the iPrint Agent

iPrint can deliver printers on a user basis and not just on a system-wide basis. This is vital in a Citrix server/Terminal Server environment, because one user removing a printer could remove the printer for every user on the system.

The iPrint client needs to be installed on each Citrix server/Terminal Server within the farm. The agent is installed from the file NIPP.EXE and should be executed after running the CHANGE USER /INSTALL command at the command prompt on the terminal server. Using the Windows Software install option under MF PS4 will also accomplish the desired outcome. This component should be configured purely for the installation of user printers.

When the iPrint client is installed on a Citrix server/Terminal Server, it cannot be auto-updated. This is a feature of a normal workstation install. After the installation of the Novell iPrint client, the client software is installed on the Start Menu, under the "Programs" menu. If selected, the following screen is displayed:


Figure 1: iPrint client screen

Please note that iCapture functionality is not currently supported on Citrix servers/Terminal Servers.

Select the Terminal Server tab to display the following dialog box:


Figure 2: iPrint–printer selection

The iPrint client is only responsible for printing to network printers. However, Citrix can also redirect print jobs to client side printers. To enable this operation, you should equip the Citrix servers/Terminal Servers with the same printer drivers that are installed on the local workstation. Citrix MetaFrame does also offer the unidriver, which will provide some client printing functionality if a specific printer driver is not available.

For a Citrix server/Terminal Server environment, select "Install user printers only." This will ensure that the printers are deployed and managed as a user printer, which is useful for the following reasons:

  • Deployment of a user printer does not require administrator rights. [Users require write rights to the C:\NDPS deployment directory on the Metaframe Servers so that the printer driver can be delivered.]

  • Removal of a user printer does not remove the printer for every user on that server. Also of benefit within a Citrix environment are control over the printer drivers available to iPrint and iPrint's ability to only deploy printer drivers that are Citrix server/Terminal Server "friendly."

iPrint Implementation

As a user authenticates to the Citrix server, a printer local to the user is configured as the default printer. Should the user authenticate from a different site, a printer near the new location is configured. Site, in the context of this section, is the device name of the thin client device.

The user's client device name is established and used as a test against a list of locations held on a NetWare/Novell Open Enterprise Server server. When a match is found in this table, an environment variable is set. This value is used to feed the command iprintcmd with the correct printer name.

This process is completely transparent to the user and has no dependency on the client device because the printer is assigned within the Citrix session. The solution requires some third-party utilities:

  • ICACLIENTINFO–This utility can write client information regarding the user's current session configuration to a file in the temp directory.
  • SetX.exe–This utility can parse a file and extract information, then write it to an environment variable. It is part of the Microsoft Windows Resource Kit for Windows 2000 and Windows 2003
  • .

iPrint Configuration

iprintcmd is used in a combination with a series of scripts that are called by either the login script or through a forced run NAL application.

The following line within the login script is responsible for kicking off the printer deployment process:
if <SESSIONNAME> <>"" and <SESSIONNAME> <>"Console" Then
#cmd /c wscript z:iPrntMFSelect.vbs
End

The IF statement is responsible for only running the script if the user has logged on from an ICA session. If the user authenticates from the normal desktop machine, then the ICA printer script is not run. Likewise if the application is run as a NAL application, the Availability option can be set to Terminal Server Required. [The ACGS implementation uses a NAL application and does not test for the Console. In this way a printer is delivered to the Console user when server Administration is being done.]

This script is split into a number of parts:

  1. Remove Current Printer if it Exists. The script reads the registry key HKCU\ENVIRONMENT\NCSLocation to determine is a default printer already exists. If so, the printer is removed using iprntcmd.
  2. Get Device Name. Using ICAClientInfo the device name is extracted and written as an environment variable under HKCU\ENVIRONMENT\var. See Figure 3 below for example.
  3. Test for Printer to Install. The Room name is extracted from the device name and tested against the list of printers located in the Sevica.ini file located in the public directory of the Novell OES Server. If a printer is found it is written to the HKCU\ENVIRONMENT\NCSLocation registry location.
  4. Read Registry and Set Printer. The HKCU\ENVIRONMENT\NCSLocation registry is read and the described printer is installed using the iprntcmd.

Figure 3 Registry Settings

Environment Setup

For the ACGS environment the following setting had to be preconfigured.

The script iPrntMFSelect.vbs and wscript.exe had to be enabled in Appsense to allow user to run them either in a login script of NAL application.

The registry keys HKCU\ENVIRONMENT\NCSLocation and HKCU\ENVIRONMENT\var had to prexist for the script to run with out errors. These keys are delivered as part of the NAL application.

As MF users are only members of the Users group they had to be given write and create rights to C:\NDPS otherwise iprntcmd would not find an associated printer. This was done through the ZEN Dynamic Local User policy. Explicit User Group rights can be given using Windows Security tools on the actual MF Servers.


Figure 4 – ZEN DLU Policy File Rights

Silent Operation

Using the original implementation of this solution, a number of ugly cmd boxes appeared on logon. In order to hide the operation and speed the process up somewhat, changes were made in the script and in the NAL application to causes the various phases to run silently. This is the purpose of various switches and seemingly unnecessary command options.

SEVICA.INI Configuration

The configuration file Sevica.ini contains a list of devices and printer names. The format can vary depending upon the variations of the script being used.

The ACGS format example is
FR07,eb-cluster-01_print_server\NDPS_FR07_HP2100,255,255.255.0
FR13,eb-cluster-01_print_server\NDPS_FR13_HP2100,255,255.255.0
The subnet mask is unused and a left over from the use of IP address configuration.

Device Naming Convention

The device naming convention used at Churchie is required for use with the as is attached script. The script looks for a minus sign as a delimiter to obtain the room name. The ACGS name convention is

BBRR-XX

where BB is the building code
where RR is the Room Number
where XX is the device number

BBRR are used to identify the printer associated to the location of the device in the sevica.ini file.

Installation Steps

Copy utilities setx and ICAClientInfo.exe to the c:\windows\system32 directory.

Copy the iPrntMFSelect.vbs to z: drive or publicly available location.

Create and copy Sevica.ini to Z: drive or publicly available location.

Install the Required Registry Keys on the Metaframe Server.

To use a NAL Application Object, use the template provided in the appendix.

To use the Login script, add the following lines to the Login script.

if <SESSIONNAME> <>"" and <SESSIONNAME> <>"Console" Then
#cmd /c wscript z:iPrntMFSelect.vbs
End

Appendix 1 – iPrntMFSelect.vbs

' Remove Current Printer if it Exists.
' VBScript.
Set Sh = CreateObject("WScript.Shell")
key = "HKEY_CURRENT_USER\ENVIRONMENT\NCSLocation"
readkey=sh.RegRead(key)
Set WshShell=WScript.CreateObject("WScript.Shell")
if (readkey<>"NotFound" and readkey<>"") then
   prm=split(readkey,"\")
   'wScript.Echo prm
   Dim strUsrCmd3
   strUsrCmd3 = "iprntcmd http://"&prm(0)+":631/ipp/"&prm(1)+" /remove"
   'wScript.Echo strUsrCmd3
   WshShell.Run strUsrCmd3,0,TRUE
end if
Set WshShell = Nothing


' Get Device Name
Set WshShell=WScript.CreateObject("WScript.Shell")
Dim strUserTmp
Dim strUsrCmd1
Dim strUsrCmd2
strUserTmp = WShShell.Environment("Process").Item("tmp")
strUsrCmd1 = "cmd /q /c ICAClientInfo >"+strUserTmp+"\list.cfg"
strUsrCmd2 = "setx var -f "+strUserTmp+"\list.cfg -a 11,1"
'wScript.Echo strUsrCmd1
WShShell.Run strUsrCmd1, 2, TRUE
'wScript.Echo strUsrCmd2
WShShell.Run strUsrCmd2, 2, TRUE
Set WshShell = Nothing


' Test for Printer to Install
Dim strClientName, strRoomName
Dim strClientNameIniString, strRoomNameIniString
Dim strUserVar
key = "HKEY_CURRENT_USER\ENVIRONMENT\var"
N:\Documentation\Metaframe\LocationBasedPrinting.sxw Page 12 of 17
readkey=sh.RegRead(key)
if (readkey<>"NotFound" and readkey<>"") then
   vUserVar = Split(readkey, "=")
   strClientName = vUserVar(1)
   vRoomVar = Split(strClientName,"-")
   strRoomName = vRoomVar(0)
end if


Dim fsoObject, open_file
Dim i, j
Dim vTable(29,3) ' Declare array of 30 rows and 3 colums
' Read a file containing a list of physical location Room Prefixs
Set fsoObject = CreateObject("Scripting.FileSystemObject")
Set open_file = fsoObject.OpenTextFile("z:\sevica.ini", 1)
i = 0
Do While False = open_file.AtEndOfStream
   vArray = Split(open_file.ReadLine(), ",")
   For j = 0 to UBound(vArray)
      vTable(i,j) = vArray(j)
   Next
      i = i + 1
Loop
open_file.Close
Set open_file = Nothing
Set fsoObject = Nothing
Dim WshShell
Dim bFound, k, intPos
Set WshShell = CreateObject("WScript.Shell")
bFound = False
For k = 0 to i - 1
   strClientNameIniString = vTable(k,0)
   ' Set the environment variable for NCSLocation
   If strClientNameIniString = strRoomName Then
   WshShell.RegWrite "HKEY_CURRENT_USER\ENVIRONMENT\NCSLocation", vTable(k,1), "REG_SZ"
   bFound = True
   Exit For
   End If
   Next
If Not bFound Then
   WshShell.RegWrite "HKEY_CURRENT_USER\ENVIRONMENT\NCSLocation", "NotFound", "REG_SZ"
End If
Set WshShell = Nothing

' Read Registry and Set Printer
' VBScript.
Set Sh = CreateObject("WScript.Shell")
   key = "HKEY_CURRENT_USER\ENVIRONMENT\NCSLocation"
   readkey=sh.RegRead(key)
if (readkey<>"NotFound" and readkey<>"") then
   prm=split(readkey,"\")
   Set WshShell=WScript.CreateObject("WScript.Shell")
   'WShShell.Run "cmd /K iprntcmd http://"&prm(0)+":631/ipp/"&prm(1)+" /Add /default", 1, TRUE
   WShShell.Run "iprntcmd http://"&prm(0)+":631/ipp/"&prm(1)+" /Add /default", 0, TRUE
   Set WshShell = Nothing
end if

Appendix 2 – NAL Application AXT File

AXT_FILE 3.1

[Application Name]
Value=RoomPrinterInstall-MRX

[Application Caption]
Value=Set Default Printer

[Application Admin Notes]
File=ADMN0029.TXT

[Application Path]
Value=wscript

[Application Flags]
Flag=Separate WOW VDM
Flag=Launch Hidden
Flag=Not a Disconnectable Application

[Application Icon]
File=APP4823.ICO

[Application Parameters]
Value=z:iPrntMFSelect.vbs

[Application Platform]
Flag=Windows 95
Flag=Windows NT

[Filter OS Version]
Type=Windows 95
Major Version=-1
Minor Version=-1
Revision Version=-1
Flag=Greater Than or Equal

[Filter OS Version]
Type=Windows NT
Major Version=-1
Minor Version=-1
Revision Version=-1
Flag=Greater Than or Equal

[Registry Key Create]
Key=HKEY_CURRENT_USER\ENVIRONMENT

[Registry Value Create]
Type=String
Flag=Write Always
Key=HKEY_CURRENT_USER\ENVIRONMENT
Name=var
Value=

[Registry Value Create]
Type=String
Flag=Write Always
Key=HKEY_CURRENT_USER\ENVIRONMENT
Name=NCSLocation
Value=

[Application Association Flags]
Flag=Launcher

[Application Version Number]
Value=5

[Application Distribution Rules]
File=DIRU18BE.XML
Show Icon=0

XML File

<?xml version="1.0" encoding="UTF-8"?><SYSTEM-REQUIREMENTS>
<TerminalServer LogicalConnector="AND">
<TRUE/>
</TerminalServer>
</SYSTEM-REQUIREMENTS>


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell