How to add a printer to a remote Samba server

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


FYI....

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


<summary>
Cross posted between imprints-devel and samba-technical.

All the source is available via anonymous CVS.  See
http://www.samba.org/cvs.html 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).
</summary>

  $ 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:
	name:[\\POGO\print$\W32X86]
              ^^^^^^^^^^^^^^^^^^^^
; This is the UNC path which we will copy the drivers to

##
## upload the driver files
##
$ bin/smbclient '\\POGO\print$' -U root%bleaK.er -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
6:HPBFDF2.DLL:HPBFDF5.PMD:HPBFDF0.DLL:HPBFDF1.HLP:NULL:RAW:HPBFDF0.DLL,HPBFDF1.DLL,HPBFDF2.DLL,HPBFDF3.DLL,HPBFDF1.HLP,MTL70UM.DLL,HPBAFD32.DLL,HPBFTM32.DLL,HPBFDF5.PMD,HPBFDF5.DLL,HPBFDF6.DLL,HPDCMON.DLL"

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:
	servername:[\\POGO]
	printername:[\\POGO\My New Printer]
	sharename:[]
	portname:[Samba Printer Port]
	drivername:[HP LaserJet 4050 Series PCL 6]
	comment:[]
	location:[]
	sepfile:[]
	printprocessor:[winprint]
	datatype:[RAW]
	parameters:[]
	attributes:[1008]
	priority:[0]
	defaultpriority:[0]
	starttime:[0]
	untiltime:[0]
	status:[2]
	cjobs:[0]
	averageppm:[0]

	Security Descriptor	revision:	1	type:	8004
	-------------------
	ACL	Num ACEs:	2	revision:	2
	---
	ACE
		Type: 0  Flags: 2  Perms:e0000000
		Permissions:	
		SID:	S-1-1-0
	ACE
		Type: 0  Flags: 2  Perms:10000000
		Permissions:	
		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
 \/    http://www.valinux.com  VA Linux Systems    gcarter at valinux.com
       http://www.samba.org       SAMBA Team           jerry at samba.org
       http://www.eng.auburn.edu/~cartegw

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




More information about the samba-technical mailing list