3.4 Example 4: Enumerating Print Jobs from All Users, Then Canceling Several Print Jobs

This example demonstrates the use case in section 2.5.3.8.2.

An administrator with appropriate privileges can view and override print jobs that are submitted by other users. This example illustrates this administrative procedure, by using only the Print System Remote Protocol [MS-RPRN].

Prerequisites

This example has the following prerequisites:

  • The administrative client is used by an administrator who has privileges for overriding the print operations of other users.

  • Either the print client or the print server supports the Print System Remote Protocol but not the Print System Asynchronous Remote Protocol [MS-PAR]. This precondition was chosen to illustrate the use of the Print System Remote Protocol.<26>

Initial System State

This example has the following initial system state:

  • Multiple users have submitted print jobs to the same print queue.

Sequence

The following diagram shows the administrative client connecting to a print queue, enumerating print jobs, and deleting a print job.

Administrative client enumerating and canceling print jobs on a print queue

Figure 25: Administrative client enumerating and canceling print jobs on a print queue

The following table shows the message groups from the preceding diagram and their purpose.

Message group

Description

References

Connecting to a print queue

The client obtains a handle to the print server.

[MS-RPRN]

section 3.1.4.2.14

Enumerating print jobs

The client obtains a list of print jobs on the print server.

[MS-RPRN]

section 3.1.4.3.3

Deleting a print job

The client deletes a print job from the print server.

[MS-RPRN]

section 3.1.4.3.1

The following steps describe this sequence:

  1. The administrative client calls the RpcOpenPrinterEx method on the print server to obtain the handle for the print queue. The print server returns the print queue handle and a success code.

  2. The administrative client calls the RpcEnumJobs method on the print server by using the print queue handle. The print server enumerates all the print jobs that are assigned to that print queue, and provides information about the print jobs, such as the names of the jobs, the IDs of the jobs, and the names of the users who submitted the jobs, and returns a success code.

  3. The administrative client displays the information about the print jobs. The administrator selects the print jobs to cancel.

  4. The administrative client repeatedly calls the RpcSetJob method by running the JOB_CONTROL_DELETE command on the print server that uses the print queue handle and then by canceling one job at a time. The print server terminates each designated print job, deleting it from the print queue and responding to each method call with a success code.

  5. The administrative client calls the RpcClosePrinter method on the print queue handle, and the print server responds with a success code.

Final State

The print queue in this example contains only print jobs that were not deleted by the administrator.