[jcifs] Accessing print shares

Mike Coleman mike.coleman at anixter.com
Thu Oct 14 16:04:31 GMT 2004


A long time ago several questions were posted about accessing print shares. The 
concensus was (I believe) to use RPC for printing. However, I was able to make 
a very minor modification to jCIFS which allows creating print jobs. I was 
wondering if making this change would be acceptable.

The change I made was in SMBFile.open0(int, int, int)

All I had to change was

if( tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS )) {
...


to

if( getType() != TYPE_PRINTER && tree.session.transport.hasCapability( 
ServerMessageBlock.CAP_NT_SMBS )) {
...


Doing so allows me to do create a print job via

new SMBFileOuputStream("smb://user:password@computer/printshare");

This DOES NOT allow me to render graphics and perform printing operations as 
might be expected, but it does allow me to write raw data to the share which, 
for me, is exactly what I want.

-mike



More information about the jcifs mailing list