Extracting usernames in enterprise print environments (e.g. SAP, Unix)
It is common in an enterprise print environment using packages such as SAP, JD Edwards, Oracle Financials or Unix systems for print jobs (e.g. batch reports) to be displayed in print queues under a system account name rather than the instigating user’s account name. The result is that all jobs printed from these programs are recorded in the PaperCut MF job logThe job log retains a history of all print jobs including the following details: the user who printed (ie. their network user ID), the time of the print event, the number of pages, document attributes such as color, duplex, grayscale, paper size, document area, paper length, where the print job originated from (the workstation name or IP address), and the document name and type (for example, a Word document’s file name). as owned by the program/system account.
In most environments, you can configure these programs or systems to write the username into the print spool fileA print spool file is generated when a user sends a document to a printer. The print spool stores the print job information, and sits in a print queue until it is retrieved and printed by a printer. (PDL). For example, you can add the username as a PJL headerAttributes in a Printer Job Language (PJL) header define print job characteristics, such as, duplex, color, paper sizes, or media trays. Many printers rely on a PJL header, though many attributes are printer/manufacturer specific.. If this is done, then PaperCut can extract the username and use it in place of the username supplied to the print queueA print queue displays information about documents that are waiting to be printed, such as, the printing status, document owner, and number of pages to print. You can use the print queue to view, pause, resume, restart, and cancel print jobs..
This feature is often combined with Username Aliases (enable Username aliasing under Options > Advanced ) when dealing with differences between the usernames used in the PaperCut MF environment and the external system or program that submits these jobs. For example, john.wayne in PaperCut MF might have jwayne as a SAP user ID. For more information see Enabling username aliasing
The extraction process, when configured, applies the following rules:
-
You can define multiple patterns to extract the username. The matching process returns the first valid result found.
-
Username extraction at the current time is not supported on Novell.
-
The username is included in the first megabyte of the spool file.
Configuring PaperCut to extract usernames from spool files
Username extraction from spool files is performed by the PaperCut Print ProviderA Print Provider is a monitoring service installed on a secondary print server to allow PaperCut to control and track printers. This monitoring component intercepts the local printing and reports the use back to the primary Application Server. and as such any configuration text described in the following steps needs to be inserted into [app_path]\providers\print\win\print-provider.conf. After a change to the config is made, restart the Print Provider service before testing.
Extracting usernames using the simple method
The Simple Method uses prefix and suffix text as static bookends for the username that is extracted. In the below example (which you can copy and paste into your print-provider.conf), the user john.wayne is extracted from the string @PJL COMMENT SAP_USER="john.wayne". Simple Matching is sufficient in the majority of customer environments.
#
# Extract username from spool files coming from our enterprise system.
# Look for a header that matches @PJL COMMENT SAP_USER="john.wayne"
#
UsernameOverridePrefix=@PJL COMMENT SAP_USER="
UsernameOverrideSuffix="
Extracting usernames using the advanced method (regular expressions)
The Advanced method adds powerful regular expression pattern plus the ability to define up to five of these patterns, labelled UsernameOverrideRegex1 to UsernameOverrideRegex5. Administrators using this method need to be familiar with regular expressions. The username is extracted from the first bracketed match group (e.g. $1).
In the example below two patterns are matched:
#
# Extract username from spool files coming from our enterprise system.
# Username may be defined in one of two formats:
# (john.wayne) XJXsetUserName
# /Author (john.wayne) def
#
UsernameOverrideRegex1=\((\S+?)\)\s*XJXsetUserName
UsernameOverrideRegex2=Author\s*\((\S+?)\)\s*def
The table below shows some further examples of username declarations seen in spool files and corresponding regular expressions that can extract the correct username.
Username in Spool File | Regular Expression to Extract Username |
---|---|
@PJL SET USERNAME="john.wayne" | @PJL\s+SET\s+USERNAME\s*=\s*"(\S+?)" |
@PJL SET USERNAMEW="john.wayne" | @PJL\s+SET\s+USERNAMEW\s*=\s*"(\S+?)" |
@PJL XJAUSERNAME = "john.wayne" | @PJL\s+XJAUSERNAME\s*=\s*"(\S+?)" |
@PJL COMMENT "Username: john.wayne" | @PJL\s+COMMENT\s+"Username\s*:\s*(\S+?)" |
@PJL COMMENT CANPJL SET USERNAME="john.wayne" | @PJL\s+COMMENT\s+CANPJL\s+SET\s+USERNAME\s*=\s*"(\S+?)" |
@PJL COMMENT "Username: john.wayne;App FileName: True Grit.doc" | @PJL\s+COMMENT\s*"Username\s*:\s*(\S+?)\s*; |
@PJL OKIAUXJOBINFO DATA="UserName=john.wayne" | @PJL\s+OKIAUXJOBINFO\s+DATA\s*=\s*"UserName\s*=\s*(\S+?)\s*" |
%%For: john.wayne | %%For:\s*\(?([\w\.-=]+?)\)?\b |
/USERNAME (john.wayne) def | /USERNAME\s*\((\S+?)\)\s*def |
/UserName (john.wayne) def | /UserName\s*\((\S+?)\)\s*def |
/Author (john.wayne) def | /Author\s*\((\S+?)\)\s*def |
(john.wayne) /RRCustomProcs /ProcSet findresource begin logusername end | \((\S+?)\)\s*/RRCustomProcs\s*/ProcSet\s+findresource\s+begin\s+logusername |
(john.wayne) XJXsetUserName | \((\S+?)\)\s*XJXsetUserName |