How to add a printer to a remote Samba server

Gerald Carter gcarter at
Thu Aug 10 14:01:05 GMT 2000


rpcclient in HEAD can now add printers on 
remote Samba servers...(I'm checking the code
in now).

Cross posted between imprints-devel and samba-technical.

All the source is available via anonymous CVS.  See for details

What follows is an interactive rpcclient session
used to explain (hopefully) the necessary steps
for adding a printer to a remote Samba host (does
not currently work with Windows NT hosts).

  $ bin/rpcclient -S pogo -U root%test
; you should logon as root for now.  I'm trying to 
; narrow this down some

  [root at POGO]$ spoolgetprinterdriverdir

## get the upload directory
  spoolgetprinterdriverdir <arch>
; The <arch> should be one of the values such as "Windows 4.0"
; "Windows NT x86", etc...

  [root at POGO]$ spoolgetprinterdriverdir "Windows NT x86"

	status:[0 (0)]
  Printer driver dir Info Level 1:
; This is the UNC path which we will copy the drivers to

## upload the driver files
$ bin/smbclient '\\POGO\print$' -U -c \
> "prompt; cd w32x86; lcd /home/gcarter/tmp/W32X86; mput *"

putting file hpbafd32.dll as \w32x86\hpbafd32.dll (10999.7 kb/s) 

## call AddPrinterDriver()
; The format of the spooladdprinterdriver parameter
; is similar to the current printers.def format in Samba 
; 2.0.7.
; spooladdprinterdriver <arch>\
;	<Long Printer Name>:<Driver File Name>:<Data File Name>:\
;	<Config File Name>:<Help File Name>:<Language Monitor Name>:\
;	<Default Data Type>:<Comma Separated list of Files>
; The only difference is the addition of the <Config File Name> 
; entry.  For NT drivers, this is an additional file.  For Win9x
; drivers, this value should be the same as the driver file name
; <arch> is the same as the possible values for 
; 'spoolgetprinterdriverdir'
; The <Language Monitor Name> is another issue.  There is no 
; SPOOLSS RPC to add a print monitor remotely.  For Samba hosts
; this string should be "NULL" (the actual string, not an emtpy
; parameter.
; It is possible to remotely add print monitors to remote NT hosts
; by adding the necessary registry key, copying the DLL to
; %SYSTEMROOT%\System32, and the restarting the spooler service
; That will come later.
; Oh and for Win9x drivers, you should use the name of the 
; associated NT driver (this means you must install an NT
; printer driver first

[root at POGO]$ spooladdprinterdriver "Windows NT x86" "HP LaserJet 4050
Series PCL

cmd_spoolss_addprinterdriver: Printer Driver [HP LaserJet 4050 Series
PCL 6] added successfully

## AddPrinterEx()
; This command takes the form of
;   spooladdprinterex <name> <shared name> <driver> <port>
; The <name> is arbitrary (this is the one that shows 
; up in the Printers Folder).
; The <shared name> must be the name of an existing printer 
; share (or Samba must be able to create the share via
; a hook script.  A list of installed printers can be retreived
; via 'spoolenum'
; > Printer Info Level 1:
; > 	flags:[800000]
; > 	name:[gutenberg]
; > 	description:[gutenberg,,cesium]
; > 	comment:[]
; > 	...
; [For the Imprints GUI tool, this should probably be a 
; a popup menu which the user can select from or override]
; The <driver name> is arbitrary.  It should be the name
; of a valid driver, but smbd does not check to make sure the
; driver is already installed so it will accept just about
; anythying.  You've been warned.
; The port is a valid port name return by 'spoolenumports 1'
; > Port Info Level 1:
; >	Port Name:	[Samba Printer Port]
; [this should be a popup menu in the Imprints GUI tool]

[root at POGO]$ spooladdprinter "My New Printer" hp-print "HP LaserJet 4050
Series PCL 6" "Samba Printer Port"

cmd_spoolss_addprinterex: [My New Printer] added successfully.

; the printer can be verified by 'spoolgetprinter <name>'

[root at POGO]$ spoolgetprinter "My New Printer"

	status:[0 (0)]
Printer Info Level 2:
	printername:[\\POGO\My New Printer]
	portname:[Samba Printer Port]
	drivername:[HP LaserJet 4050 Series PCL 6]

	Security Descriptor	revision:	1	type:	8004
	ACL	Num ACEs:	2	revision:	2
		Type: 0  Flags: 2  Perms:e0000000
		SID:	S-1-1-0
		Type: 0  Flags: 2  Perms:10000000
		SID:	S-1-5-21-3315383027-3203085638-3440197039-1000

	Owner SID:	S-1-5-21-3315383027-3203085638-3440197039-1000

Cheers, jerry
   /\  Gerald (Jerry) Carter                     Professional Services
 \/  VA Linux Systems    gcarter at       SAMBA Team           jerry at

       "...a hundred billion castaways looking for a home."
                                - Sting "Message in a Bottle" ( 1979 )

More information about the samba-technical mailing list