3.2.5.4 NetPrintQEnum Command

The Remote Administration Protocol server MUST process the NetPrintQEnumRequest as follows:

  1. The server MUST validate that the incoming ParamDesc field of the Remote Administration Protocol request contains the ASCII string "WrLeh"; if it does not, the server SHOULD format a Remote Administration Protocol response with the Win32ErrorCode set to ERROR_INVALID_PARAMETER (0x0057), and then return the response to the client.<71>

  2. If the information level is any value other than 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, or 0x0005, the server implementing NetPrintQEnum MUST set the Win32ErrorCode value in the Remote Administration Protocol response message to ERROR_INVALID_LEVEL (0x007C).

  3. The server MUST call RpcOpenPrinter as specified in [MS-RPRN]  3.1.4.2.2, with the following parameters:

    Parameter

    Value

    pPrinterName

    The local machine name

    pDatatype

    "RAW"

    pDevModeContainer

    NULL

    AccessRequired

    PRINTER_ACCESS_USE

    If the call succeeds, the server MUST call RpcEnumPrinters as specified in [MS-RPRN], with the following parameters:

    Parameter

    Value

    Flags

    PRINTER_ENUM_SHARED | PRINTER_ENUM_NAME

    Name

    The local machine name

    Level

    2

    pPrinterEnum

    NULL

    cbBuf

    0

    The server MUST then allocate a buffer of the size, in bytes, specified in pcbNeeded returned from RpcEnumPrinters, and it MUST call RpcEnumPrinters again, using the following parameters:

    Parameter

    Value

    Flags

    PRINTER_ENUM_SHARED | PRINTER_ENUM_NAME

    Name

    The local machine name

    Level

    2

    pPrinterEnum

    A pointer to a buffer of size pcbNeeded

    cbBuf

    The value of pcbNeeded

    If the call succeeds, the server MUST fill the RAPDataOut field of the response based on the value of NetPrintQEnumRequest.InfoLevel as follows. The server MUST set EntriesReturned to the number of PrintQueue structures returned in the response, and EntriesAvailable to the total number of entries returned from RpcEnumPrinters.

    InfoLevel0: The server MUST fill in an array of PrintQueue0 structures using the following mapping:

    PrintQueue0

    PRINTER_INFO_2

    PrintQName

    If pPrinterName contains a backslash, QueueName is set to the remaining portion of pPrinterName after the backslash character.

    InfoLevel1: The server MUST fill in an array of PrintQueue1 structures using the following mapping:

    PrintQueue1

    PRINTER_INFO_2

    PrintQName

    If pPrinterName contains a backslash, QueueName is set to the remaining portion of pPrinterName after the backslash character. If pPrinterName does not contain a backslash, QueueName is set to pPrinterName.

    Priority

    Priority

    StartTime

    StartTime

    UntilTime

    UntilTime

    SeparatorPageFilenameLow / SeparatorPageFilenameHigh

    pSepFile

    PrintProcessorDllNameLow / PrintProcessorDllNameHigh

    pPrintProcessor

    PrintDestinationsNameLow / PrintDestinationsNameHigh

    pPortName

    PrintParametersStringLow / PrintParametersStringHigh

    pParameters

    CommentStringLow / CommentStringHigh

    pComment

    PrintQStatus

    A status value as specified in section 3.2.5.4.1.

    PrintJobCount

    cJobs

    InfoLevel2: The server MUST fill an array of PrintQueue1 structures as specified for InfoLevel1, with the following changes. For each PrintQueue1 structure, the server MUST enumerate the jobs pending for the print queue by calling RpcEnumJobs as specified in [MS-RPRN]  3.1.4.3.3, providing the following parameters:

    Parameter

    Value

    hPrinter

    The handle returned from the RpcOpenPrinter call.

    FirstJob

    0

    NoJobs

    PrintQueue1.PrintJobCount

    Level

    2

    pJob

    NULL

    cbBuf

    0

    The server MUST then allocate a buffer of the size, in bytes, specified in pcbNeeded returned from RpcEnumJobs, and MUST call RpcEnumJobs again, using the following parameters:

    Parameter

    Value

    hPrinter

    The handle returned from the RpcOpenPrinter call.

    FirstJob

    0

    NoJobs

    PrintQueue1.PrintJobCount

    Level

    2

    pJob

    A pointer to a buffer of size pcbNeeded.

    cbBuf

    pcbNeeded

    If the call succeeds, the server MUST append the returned information to the PrintQueue1 structure.  The mapping between JOB_INFO_2 and PrintJobInfo1 structures is specified in NetPrintJobGetInfo Command. If all the print jobs returned will not fit into the response, the server MUST NOT return any print jobs.

    InfoLevel3: The server MUST fill an array of PrintQueue3 structures by using the following mapping. The server MUST set EntriesReturned to the number of PrintQueue3 structures returned in the response, and set EntriesAvailable to the total number of entries returned from RpcEnumPrinters.

    PrintQueue3

    PRINTER_INFO_2

    PrintQName

    If pPrinterName contains a backslash, QueueName is set to the remaining portion of pPrinterName after the backslash character. If pPrinterName does not contain a backslash, QueueName is set to pPrinterName.

    Priority

    Priority

    StartTime

    StartTime

    UntilTime

    UntilTime

    SeparatorPageFilenameLow / SeparatorPageFilenameHigh

    pSepFile

    PrintProcessorDllNameLow / PrintProcessorDllNameHigh

    pPrintProcessor

    PrintParametersStringLow / PrintParametersStringHigh

    pParameters

    CommentStringLow / CommentStringHigh

    pComment

    PrintQStatus

    A status value as specified in 3.2.5.4.1

    PrintJobCount

    cJobs

    PrintersLow / PrintersHigh

    pPortName

    DriverNameLow / DriverNameHigh

    pDriverName

    PrintDriverDataLow / PrintDriverDataHigh

    NULL

    InfoLevel4: The server MUST fill an array of PrintQueue3 structures as specified for InfoLevel3, with the following changes. For each PrintQueue3 structure, the server MUST enumerate the jobs pending for the print queue by calling RpcEnumJobs as specified in [MS-RPRN] 3.1.4.3.3 and providing the following parameters:

    Parameter

    Value

    hPrinter

    The handle returned from the RpcOpenPrinter call.

    FirstJob

    0

    NoJobs

    PrintQueue1.PrintJobCount

    Level

    2

    pJob

    NULL

    cbBuf

    0

    The server MUST then allocate a buffer of the size in bytes specified in pcbNeeded returned from RpcEnumJobs, and MUST call RpcEnumJobs again, with the following parameters:

    Parameter

    Value

    hPrinter

    The handle returned from the RpcOpenPrinter call.

    FirstJob

    0

    NoJobs

    PrintQueue1.PrintJobCount

    Level

    2

    pJob

    A pointer to a buffer of size pcbNeeded

    cbBuf

    The value of pcbNeeded

    If the call succeeds, the server MUST append the returned PrintJobInfo2 structures to the PrintQueue3 structure. The mapping between the JOB_INFO_2 and PrintJobInfo2 structures is specified in 3.2.5.7. If all the print jobs returned will not fit into the response, the server MUST NOT return any print jobs.

  4. If the response EntriesReturned field is less than the response EntriesAvailable field, the Remote Administration Protocol NetPrintQEnum server MUST set the Win32ErrorCode value in the Remote Administration Protocol response message to ERROR_MORE_DATA (0x00EA).

  5. If any other errors occur during the response processing, the Remote Administration Protocol server MUST fill in the Win32ErrorCode value in the Remote Administration Protocol response message with the Win32 error code corresponding to the error. Otherwise, the Remote Administration Protocol server MUST set Win32ErrorCode to ERROR_SUCCESS (0X0000).