[jcifs] Shared Printing - Figured it out (sorta)

Michael.Colemen at anixter.com Michael.Colemen at anixter.com
Wed Jun 18 05:53:41 EST 2003

I think I've found out why shared printing is not working (invalid
parameter error). In the SmbFile.open(int) method there is a query of the
server capabilities. If CAP_NT_SMBS is supported, then a SmbComNTCreateAndX
is performed. Otherwise a SmbComOpenAndX() is performed. I'm not sure if
there is any correlation, but in the SMB documentation I found, there is a
OPEN_PRINT_FILE but not a CREATE_PRINT_FILE. In any case, when I remove the
check for capabilities, I am successful at printing.

//if( tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS
)) {
//    SmbComNTCreateAndXResponse response = new
//    send( new SmbComNTCreateAndX( unc, flags, null, shareAccess ),
response );
//    fid = response.fid;
//} else {
      SmbComOpenAndXResponse response = new SmbComOpenAndXResponse();
      send( new SmbComOpenAndX( unc, flags, null ), response );
      fid = response.fid;

Anyway, I figured as an exercise I'd write my own SmbComOpenPrinterAndX and
SmbComOpenPrinterAndXResponse classes. If anyone is interested I can post
the files.

I also noticed there is a GET_PRINT_QUEUE command which one case use to
query a print que for all sorts of status information but haven't gotten
around to coding that.


More information about the jcifs mailing list