Another set of updates; includes the new examples code and use of
[Samba.git] / docs / Samba3-HOWTO / TOSHARG-Printing.xml
blobb5488fca6525290cfa59cea88a87ab17246cedf2
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
3 <chapter id="printing">
5 <chapterinfo>
6         <author>
7                 <firstname>Kurt</firstname><surname>Pfeifle</surname>
8                 <affiliation>
9                         <orgname> Danka Deutschland GmbH </orgname>
10                         <address><email>kpfeifle@danka.de</email></address>
11                 </affiliation>
12         </author>
13         &author.jerry;
14         &author.jht;
15         <pubdate>May 31, 2003</pubdate>
16 </chapterinfo>
18 <title>Classical Printing Support</title>
20 <sect1>
21 <title>Features and Benefits</title>
23 <para>
24 Printing is often a mission-critical service for the users. Samba can
25 provide this service reliably and seamlessly for a client network
26 consisting of Windows workstations.
27 </para>
29 <para>
30 A Samba print service may be run on a Stand-alone or Domain Member server,
31 side by side with file serving functions, or on a dedicated print server.
32 It can be made as tight or as loosely secured as needs dictate. Configurations
33 may be simple or complex. Available authentication schemes are essentially
34 the same as described for file services in previous chapters. Overall,
35 Samba's printing support is now able to replace an NT or Windows 2000
36 print server full-square, with additional benefits in many cases. Clients
37 may download and install drivers and printers through their familiar
38 <quote>Point'n'Print</quote> mechanism. Printer installations executed by
39 <quote>Logon Scripts</quote> are no problem. Administrators can upload and
40 manage drivers to be used by clients through the familiar <quote>Add Printer
41 Wizard</quote>. As an additional benefit, driver and printer management may
42 be run from the command line or through scripts, making it more efficient
43 in case of large numbers of printers. If a central accounting of print jobs
44 (tracking every single page and supplying the raw data for all sorts of
45 statistical reports) is required, this function is best supported by
46 the newer Common UNIX Printing System (CUPS)
47 as the print subsystem underneath the Samba hood.
48 </para>
50 <para>
51 This chapter deals with the foundations of Samba printing as they
52 are implemented by the more traditional UNIX (BSD and System V-style)
53 printing systems. Many things covered in this chapter apply also to CUPS.
54 If you use CUPS, you may be tempted
55 to jump to the next chapter but you will certainly miss a few things if
56 you do. It is recommended that you read this chapter as well as <link
57 linkend="CUPS-printing">CUPS Printing Support</link>.
58 </para>
60 <note>
61 <para>
62 Most of the following examples have been verified on Windows XP
63 Professional clients. Where this document describes the responses to
64 commands given, bear in mind that Windows 200x/XP clients are quite
65 similar, but may differ in minor details. Windows NT is somewhat different
66 again.
67 </para>
68 </note>
70 </sect1>
72 <sect1>
73 <title>Technical Introduction</title>
75 <para>
76 Samba's printing support always relies on the installed print subsystem
77 of the UNIX OS it runs on. Samba is a <quote>middleman.</quote> It takes
78 print files from Windows (or other SMB) clients and passes them to the real
79 printing system for further processing, therefore, it needs to communicate with
80 both sides: the Windows print clients and the UNIX printing system. Hence, we
81 must differentiate between the various client OS types, each of which behave
82 differently, as well as the various UNIX print subsystems, which themselves
83 have different features and are accessed differently.
84 </para>
86 <para>
87 This deals with the traditional way of UNIX printing. The next chapter
88 covers in great detail the more modern <emphasis>Common UNIX Printing
89 System</emphasis> (CUPS).
90 </para>
92 <important><para>CUPS users, be warned: do not just jump on to the next
93 chapter. You might miss important information only found here!
94 </para></important>
96 <para>
97 It is apparent from postings on the Samba mailing list that print configuration
98 is one of the most problematic aspects of Samba administration today. Many
99 new Samba administrators have the impression that Samba performs some sort
100 of print processing. Rest assured, Samba does not perform any type of print
101 processing. It does not do any form of print filtering.
102 </para>
104 <para>
105 Samba obtains from its clients a data stream (print job) that it spools to a
106 local spool area. When the entire print job has been received, Samba invokes
107 a local UNIX/Linux print command and passes the spooled file to it. It is
108 up to the local system printing subsystems to correctly process the print
109 job and to submit it to the printer.
110 </para>
112 <sect2>
113 <title>Client to Samba Print Job Processing</title>
115 <para>
116 Successful printing from a Windows client via a Samba print server to a UNIX
117 printer involves six (potentially seven) stages:
118 </para>
120 <orderedlist>
121 <listitem><para>Windows opens a connection to the printer share.</para></listitem>
123 <listitem><para>Samba must authenticate the user.</para></listitem>
125 <listitem><para>Windows sends a copy of the print file over the network
126 into Samba's spooling area.</para></listitem>
128 <listitem><para>Windows closes the connection.</para></listitem>
130 <listitem><para>Samba invokes the print command to hand the file over
131 to the UNIX print subsystem's spooling area.</para></listitem>
133 <listitem><para>The UNIX print subsystem processes the print job.</para></listitem>
135 <listitem><para>The print file may need to be explicitly deleted
136 from the Samba spooling area. This item depends on your print spooler
137 configuration settings.</para></listitem>
139 </orderedlist>
140 </sect2>
142 <sect2>
143 <title>Printing Related Configuration Parameters</title>
145 <para>
146 There are a number of configuration parameters to control Samba's
147 printing behavior. Please refer to the man page for &smb.conf; for an
148 overview of these. As with other parameters, there are Global Level
149 (tagged with a <emphasis>G</emphasis> in the listings) and Service Level
150 (<emphasis>S</emphasis>) parameters.
151 </para>
153 <variablelist>
154         <varlistentry><term>Global Parameters</term>
155                 <listitem><para> These <emphasis>may not</emphasis> go into
156                 individual share definitions. If they go in by error,
157                 the <command>testparm</command> utility can discover this
158                 (if you run it) and tell you so.
159                 </para></listitem>
160         </varlistentry>
162         <varlistentry><term>Service Level Parameters</term>
163                 <listitem><para> These may be specified in the
164                 <smbconfsection name="[global]"/> section of &smb.conf;.
165                 In this case they define the default behavior of all individual
166                 or service level shares (provided they do not have a different
167                 setting defined for the same parameter, thus overriding the
168                 global default).
169                 </para></listitem>
170         </varlistentry>
171 </variablelist>
172 </sect2>
174 </sect1>
176 <sect1>
177 <title>Simple Print Configuration</title>
179 <para>
180 <link linkend="simpleprc">Following example</link> shows a simple printing configuration.
181 If you compare this with your own, you may find 
182 additional parameters that have been pre-configured by your OS
183 vendor. Below is a discussion and explanation of the
184 parameters. This example does not use many parameters.
185 However, in many environments these are enough to provide a valid
186 &smb.conf; file that enables all clients to print.
187 </para>
189 <example id="simpleprc">
190 <title>Simple configuration with BSD printing</title>
191 <smbconfblock>
192 <smbconfsection name="[global]"/>
193 <smbconfoption name="printing">bsd</smbconfoption>
194 <smbconfoption name="load printers">yes</smbconfoption>
196 <smbconfsection name="[printers]"/>
197 <smbconfoption name="path">/var/spool/samba</smbconfoption>
198 <smbconfoption name="printable">yes</smbconfoption>
199 <smbconfoption name="public">yes</smbconfoption>
200 <smbconfoption name="writable">no</smbconfoption>
201 </smbconfblock>
202 </example>
204 <para>
205 This is only an example configuration. Samba assigns default values to
206 all configuration parameters. The defaults are conservative
207 and sensible. When a parameter is specified in the &smb.conf; file, this
208 overwrites the default value. The <command>testparm</command> utility when
209 run as root is capable of reporting all setting, both default as well as
210 &smb.conf; file settings. <command>Testparm</command> gives warnings for all
211 mis-configured settings. The complete output is easily 340 lines and more,
212 so you may want to pipe it through a pager program.
213 </para>
215 <para>
216 The syntax for the configuration file is easy to grasp. You should
217 know that  is not very picky about its syntax. As has been explained
218 elsewhere in this document, Samba tolerates some spelling errors (such
219 as <smbconfoption name="browseable"/> instead of
220 <smbconfoption name="browseable"/>), and spelling is
221 case-insensitive. It is permissible to use <parameter>Yes/No</parameter>
222 or <parameter>True/False</parameter> for Boolean settings. Lists of names
223 may be separated by commas, spaces or tabs.
224 </para>
226 <sect2>
227 <title>Verifying Configuration with <command>testparm</command></title>
229 <para>
230 To see all (or at least most) printing-related settings in Samba, including
231 the implicitly used ones, try the command outlined below. This command greps
232 for all occurrences of <constant>lp, print, spool, driver, ports</constant>
233 and <constant>[</constant> in testparms output. This provides a convenient
234 overview of the running <command>smbd</command> print configuration. This
235 command does not show individually created printer shares or the spooling
236 paths they may use. Here is the output of my Samba setup, with settings
237 shown in <link linkend="simpleprc">the example above</link>:
238 </para>
240 <para><screen>
241 &rootprompt;<userinput>testparm -s -v | egrep "(lp|print|spool|driver|ports|\[)"</userinput>
242  Load smb config files from /etc/samba/smb.conf
243  Processing section "[homes]"
244  Processing section "[printers]"
246  [global]
247         smb ports = 445 139
248         lpq cache time = 10
249         load printers = Yes
250         printcap name = /etc/printcap
251         disable spoolss = No
252         enumports command =
253         addprinter command = 
254         deleteprinter command = 
255         show add printer wizard = Yes
256         os2 driver map =
257         printer admin =
258         min print space = 0
259         max print jobs = 1000
260         printable = No
261         printing = bsd
262         print command = lpr -r -P'%p' %s
263         lpq command = lpq -P'%p'
264         lprm command = lprm -P'%p' %j
265         lppause command =
266         lpresume command =
267         printer name =
268         use client driver = No
270  [homes]
272  [printers]
273         path = /var/spool/samba
274         printable = Yes
275 </screen>
276 </para>
278 <para>
279 You can easily verify which settings were implicitly added by Samba's
280 default behavior. <emphasis>Remember: it may
281 be important in your future dealings with Samba.</emphasis>
282 </para>
284 <note><para> testparm in Samba-3 behaves differently from that in 2.2.x: used
285 without the <quote>-v</quote> switch it only shows you the settings actually
286 written into! To see the complete
287 configuration used, add the <quote>-v</quote> parameter to testparm.</para></note>
289 </sect2>
291 <sect2>
292 <title>Rapid Configuration Validation</title>
294 <para>
295 Should you need to troubleshoot at any stage, please always come back
296 to this point first and verify if <command>testparm</command> shows the parameters you
297 expect. To give you a warning from personal experience,
298 try to just comment out the <smbconfoption name="load printers"/>
299 parameter. If your 2.2.x system behaves like mine, you'll see this:
300 </para>
302 <para><screen>
303 &rootprompt;grep "load printers" /etc/samba/smb.conf
304         #  load printers = Yes
305         # This setting is commented out!!
307 &rootprompt;testparm -v /etc/samba/smb.conf | egrep "(load printers)"
308         load printers = Yes
309 </screen></para>
311 <para>
312 I assumed that commenting out of this setting should prevent Samba from
313 publishing my printers, but it still did. It took some time to figure out
314 the reason. But I am no longer fooled ... at least not by this.
315 </para>
317 <para><screen>
318 &rootprompt;<userinput>grep -A1 "load printers" /etc/samba/smb.conf</userinput>
319         load printers = No
320         # The above setting is what I want!
321         #  load printers = Yes
322         # This setting is commented out!
324 &rootprompt;<userinput>testparm -s -v smb.conf.simpleprinting | egrep "(load printers)"</userinput>
325         load printers = No
327 </screen></para>
329 <para>
330 Only when the parameter is explicitly set to
331 <smbconfoption name="load printers">No</smbconfoption>
332 would Samba conform with my intentions. So, my strong advice is:
333 </para>
335 <itemizedlist>
336 <listitem><para>Never rely on commented out parameters.</para></listitem>
338 <listitem><para>Always set parameters explicitly as you intend them to
339 behave.</para></listitem>
341 <listitem><para>Use <command>testparm</command> to uncover hidden
342 settings that might not reflect your intentions.</para></listitem>
344 </itemizedlist>
346 <para>
347 The following is the most minimal configuration file:
348 <screen>
349 &rootprompt;<userinput>cat /etc/samba/smb.conf-minimal</userinput>
350         [printers]
351 </screen></para>
353 <para>
354 This example should show that you can use testparm to test any Samba
355 configuration file. Actually, we encourage you <emphasis>not</emphasis>
356 to change your working system (unless you know exactly what you are
357 doing). Don't rely on the assumption that changes will only take effect after
358 you re-start smbd!  This is not the case. Samba re-reads it every 60 seconds
359 and on each new client connection. You might have to face changes for your
360 production clients that you didn't intend to apply. You will now
361 note a few more interesting things; <command>testparm</command> is useful to
362 identify what the Samba print configuration would be if you used this minimalistic
363 configuration. Here is what you can expect to find:
364 </para>
366 <para><screen>
367 &rootprompt;<userinput>testparm -v smb.conf-minimal | egrep "(print|lpq|spool|driver|ports|[)"</userinput>
368  Processing section "[printers]"
369  WARNING: [printers] service MUST be printable!
370  No path in service printers - using /tmp
372         lpq cache time = 10
373         load printers = Yes
374         printcap name = /etc/printcap
375         disable spoolss = No
376         enumports command =
377         addprinter command =
378         deleteprinter command =
379         show add printer wizard = Yes
380         os2 driver map =
381         printer admin =
382         min print space = 0
383         max print jobs = 1000
384         printable = No
385         printing = bsd
386         print command = lpr -r -P%p %s
387         lpq command = lpq -P%p
388         printer name =
389         use client driver = No
391  [printers]
392         printable = Yes
394 </screen></para>
396 <para>
397 testparm issued two warnings:
398 </para>
400 <itemizedlist>
401         <listitem><para>We did not specify the <smbconfsection name="[printers]"/> section as printable.</para></listitem>
402         <listitem><para>We did not tell Samba which spool directory to use.</para></listitem>
403 </itemizedlist>
405 <para>
406 However, this was not fatal and Samba will default to values that will
407 work. Please, do not rely on this and do not use this example. This was
408 included to encourage you to be careful to design and specify your setup to do
409 precisely what you require. The outcome on your system may vary for some
410 parameters given, since Samba may have been built with  different compile-time
411 options. <emphasis>Warning:</emphasis> do not put a comment sign
412 <emphasis>at the end</emphasis> of a valid line. It will cause the parameter
413 to be ignored (just as if you had put the comment sign at the front). At first
414 I regarded this as a bug in my Samba versions. But the man page clearly says:
415 <quote>Internal whitespace in a parameter value is retained verbatim.</quote>
416 This means that a line consisting of, for example:
417 </para>
419 <para><smbconfblock>
420 <smbconfcomment>This defines LPRng as the printing system</smbconfcomment>
421 <smbconfoption name="printing"> lprng</smbconfoption>
422 </smbconfblock></para>
424 <para>
425 will regard the whole of the string after the
426 <quote><constant>=</constant></quote> sign as the value you want to
427 define. This is an invalid value that will be ignored and a default
428 value will be
429 used in its place.
430 </para>
431 </sect2>
432 </sect1>
434 <sect1>
435 <title>Extended Printing Configuration</title>
437 <para>
438 <link linkend="extbsdpr">Next configuration</link> shows a more verbose example configuration
439 for print-related settings in a BSD-style printing environment. What follows
440 is a discussion and explanation of the various parameters. We chose to
441 use BSD-style printing here because it is still the most commonly used
442 system on legacy UNIX/Linux installations. New installations predominantly
443 use CUPS, which is discussed in a separate chapter. The example explicitly
444 names many parameters that do not need to be specified because they are set
445 by default. You could use a much leaner &smb.conf; file. Alternately, you can use
446 <command>testparm</command> or <command>SWAT</command> to optimize the &smb.conf;
447 file to remove all parameters that are set at default.
448 </para>
450 <example id="extbsdpr">
451         <title>Extended BSD Printing Configuration</title>
452         <smbconfblock>
453 <smbconfsection name="[global]"/>
454 <smbconfoption name="printing">bsd</smbconfoption>
455 <smbconfoption name="load printers">yes</smbconfoption>
456 <smbconfoption name="show add printer wizard">yes</smbconfoption>
457 <smbconfoption name="printcap name">/etc/printcap</smbconfoption>
458 <smbconfoption name="printer admin">@ntadmin, root</smbconfoption>
459 <smbconfoption name="max print jobs">100</smbconfoption>
460 <smbconfoption name="lpq cache time">20</smbconfoption>
461 <smbconfoption name="use client driver">no</smbconfoption>
463 <smbconfsection name="[printers]"/>
464 <smbconfoption name="comment">All Printers</smbconfoption>
465 <smbconfoption name="printable">yes</smbconfoption>
466 <smbconfoption name="path">/var/spool/samba</smbconfoption>
467 <smbconfoption name="browseable">no</smbconfoption>
468 <smbconfoption name="guest ok">yes</smbconfoption>
469 <smbconfoption name="public">yes</smbconfoption>
470 <smbconfoption name="read only">yes</smbconfoption>
471 <smbconfoption name="writable">no       </smbconfoption>
473 <smbconfsection name="[my_printer_name]"/>
474 <smbconfoption name="comment">Printer with Restricted Access</smbconfoption>
475 <smbconfoption name="path">/var/spool/samba_my_printer</smbconfoption>
476 <smbconfoption name="printer admin">kurt</smbconfoption>
477 <smbconfoption name="browseable">yes</smbconfoption>
478 <smbconfoption name="printable">yes</smbconfoption>
479 <smbconfoption name="writable">no</smbconfoption>
480 <smbconfoption name="hosts allow">0.0.0.0</smbconfoption>
481 <smbconfoption name="hosts deny">turbo_xp, 10.160.50.23, 10.160.51.60</smbconfoption>
482 <smbconfoption name="guest ok">no</smbconfoption>
483 </smbconfblock></example>
485 <para>
486 This is an example configuration. You may not find all the settings that are in 
487 the configuration file that was provided by the OS vendor. Samba configuration
488 parameters, if not explicitly set default to a sensible value.
489 To see all settings, as <constant>root</constant> use the <command>testparm</command>
490 utility. <command>testparm</command> gives warnings for mis-configured settings.
491 </para>
493 <sect2>
494 <title>Detailed Explanation Settings</title>
496 <para>
497 The following is a discussion of the settings from above shown example.
498 </para>
500 <sect3>
501 <title>The [global] Section</title>
503 <para>
504 The <smbconfsection name="[global]"/> section is one of four special
505 sections (along with [<smbconfsection name="[homes]"/>,
506 <smbconfsection name="[printers]"/>
507 and <smbconfsection name="[print$]"/>...). The
508 <smbconfsection name="[global]"/> contains all parameters which apply
509 to the server as a whole. It is the place for parameters that have only a
510 global meaning. It may also contain service level parameters that then define
511 default settings for all other sections and shares. This way you can simplify
512 the configuration and avoid setting the same value repeatedly. (Within each
513 individual section or share you may, however, override these globally set
514 share settings and specify other values).
515 </para>
517 <variablelist>
518         <varlistentry><term><smbconfoption name="printing">bsd </smbconfoption></term>
519                 <listitem><para>Causes Samba to use default print commands
520                 applicable for the BSD (also known as RFC 1179 style or LPR/LPD) printing
521                 system. In general, the <parameter>printing</parameter> parameter informs Samba about the
522                 print subsystem it should expect. Samba supports CUPS, LPD, LPRNG,
523                 SYSV, HPUX, AIX, QNX, and PLP. Each of these systems defaults to a
524                 different <smbconfoption name="print command"/> (and other queue control
525                 commands).</para>
527                 <caution><para>The <smbconfoption name="printing"/> parameter is
528                 normally a service level parameter. Since it is included here in the
529                 <smbconfsection name="[global]"/> section, it will take effect for all
530                 printer shares that are not defined differently. Samba-3 no longer
531                 supports the SOFTQ printing system.</para></caution>
532         </listitem></varlistentry>
534         <varlistentry><term><smbconfoption name="load printers">yes </smbconfoption></term>
535                 <listitem><para>Tells Samba to create automatically all
536                 available printer shares. Available printer shares are discovered by
537                 scanning the printcap file. All created printer shares are also loaded
538                 for browsing. If you use this parameter, you do not need to specify
539                 separate shares for each printer. Each automatically created printer
540                 share will clone the configuration options found in the
541                 <smbconfsection name="[printers]"/> section. (The <parameter>load printers
542                 = no</parameter> setting will allow you to specify each UNIX printer
543                 you want to share separately, leaving out some you do not want to be
544                 publicly visible and available).</para>
545         </listitem></varlistentry>
547         <varlistentry><term><smbconfoption name="show add printer wizard">yes </smbconfoption></term>
548                 <listitem><para>Setting is normally enabled by default (even if the parameter is not specified in &smb.conf;).
549                 It causes the <guiicon>Add Printer Wizard</guiicon> icon to appear
550                 in the <guiicon>Printers</guiicon> folder of the Samba host's
551                 share listing (as shown in <guiicon>Network Neighborhood</guiicon> or
552                 by the <command>net view</command> command). To disable it, you need to
553                 explicitly set it to <constant>no</constant> (commenting it out
554                 will not suffice). The <parameter>Add Printer Wizard</parameter> lets you upload printer
555                 drivers to the <smbconfsection name="[print$]"/> share and associate it
556                 with a printer (if the respective queue exists before the
557                 action), or exchange a printer's driver against any other previously
558                 uploaded driver.</para>
559         </listitem></varlistentry>
561         <varlistentry><term><smbconfoption name="max print jobs">100 </smbconfoption></term>
562                 <listitem><para>Sets the upper limit to 100 print jobs
563                 being active on the Samba server at any one time. Should a client
564                 submit a job that exceeds this number, a <quote>no more space
565                 available on server</quote> type of error message will be returned by
566                 Samba to the client. A setting of zero (the default) means there is
567                 <emphasis>no</emphasis> limit at all.
568         </para></listitem></varlistentry>
570         <varlistentry><term><smbconfoption name="printcap name">/etc/printcap </smbconfoption></term>
571                 <listitem><para>Tells Samba where to look for a list of
572                 available printer names. Where CUPS is used, make sure that a printcap
573                 file is written. This is controlled by the <constant>Printcap</constant> directive in the 
574                 <filename>cupsd.conf</filename> file.
575         </para></listitem></varlistentry>
577         <varlistentry><term><smbconfoption name="printer admin">@ntadmin </smbconfoption></term>
578                 <listitem><para>Members of the ntadmin group should be able to add
579                 drivers and set printer properties (<constant>ntadmin</constant> is only an example name,
580                 it needs to be a valid UNIX group name); root is implicitly always a
581                 <smbconfoption name="printer admin"/>. The @ sign precedes group names in the
582                 <filename>/etc/group</filename>. A printer admin can do anything to
583                 printers via the remote administration interfaces offered by MS-RPC
584                 (see below). In larger installations, the <smbconfoption name="printer admin"/>
585                 parameter is normally a per-share parameter. This permits different groups to administer each printer share.
586         </para></listitem></varlistentry>
588         <varlistentry><term><smbconfoption name="lpq cache time">20 </smbconfoption></term>
589                 <listitem><para>Controls the cache time for the results of the
590                 lpq command. It prevents the lpq command being called too often and
591                 reduces the load on a heavily used print server.
592         </para></listitem></varlistentry>
594         <varlistentry><term><smbconfoption name="use client driver">no </smbconfoption></term>
595                 <listitem><para>If set to <constant>yes</constant>, only 
596                 takes effect for Windows NT/200x/XP clients (and not for Win 95/98/ME). Its
597                 default value is <constant>No</constant> (or <constant>False</constant>).
598                 It must <emphasis>not</emphasis> be enabled on print shares 
599                 (with a <constant>yes</constant> or <constant>true</constant> setting) that
600                 have valid drivers installed on the Samba server. For more detailed
601                 explanations see the &smb.conf; man page.
602         </para></listitem></varlistentry>
603 </variablelist>
605 </sect3>
607 <sect3 id="ptrsect">
608 <title>The [printers] Section</title>
610 <para>
611 This is the second special section. If a section with this name appears in
612 the &smb.conf;, users are able to connect to any printer specified in the
613 Samba host's printcap file, because Samba on startup then creates a printer
614 share for every printer name it finds in the printcap file. You could regard
615 this section as a general convenience shortcut to share all printers with
616 minimal configuration. It is also a container for settings that should
617 apply as default to all printers. (For more details see the &smb.conf;
618 man page.) Settings inside this container must be Share Level parameters.
619 </para>
621 <variablelist>
622         <varlistentry><term><smbconfoption name="comment">All printers </smbconfoption></term>
623                 <listitem><para>
624                 The <smbconfoption name="comment"/> is shown next to the share if
625                 a client queries the server, either via <guiicon>Network Neighborhood</guiicon> or with
626                 the <command>net view</command> command to list available shares.
627                 </para></listitem>
628         </varlistentry>
630         <varlistentry><term><smbconfoption name="printable">yes </smbconfoption></term>
631                 <listitem><para>
632                 The <smbconfsection name="[printers]"/> service <emphasis>must</emphasis>
633                 be declared as printable. If you specify otherwise, smbd will refuse to load  at
634                 startup. This parameter allows connected clients to open, write to and submit spool files
635                 into the directory specified with the <smbconfoption name="path"/>
636                 parameter for this service. It is used by Samba to differentiate printer shares from
637                 file shares. 
638                 </para></listitem>
639         </varlistentry>
641         <varlistentry><term><smbconfoption name="path">/var/spool/samba </smbconfoption></term>
642                 <listitem><para>
643                 Must point to a directory used by Samba to spool incoming print files. <emphasis>It
644                 must not be the same as the spool directory specified in the configuration of your UNIX
645                 print subsystem!</emphasis> The path typically points to a directory that is world
646                 writable, with the <quote>sticky</quote> bit set to it.
647                 </para></listitem>
648         </varlistentry>
650         <varlistentry><term><smbconfoption name="browseable">no </smbconfoption></term>
651                 <listitem><para>
652                 Is always set to <constant>no</constant> if
653                 <smbconfoption name="printable">yes</smbconfoption>. It makes
654                 the <smbconfsection name="[printer]"/> share itself invisible in the list of
655                 available shares in a <command>net view</command> command or in the Explorer browse
656                 list. (You will of course see the individual printers).
657                 </para></listitem>
658         </varlistentry>
660         <varlistentry><term><smbconfoption name="guest ok">yes </smbconfoption></term>
661                 <listitem><para>
662                 If this parameter is set to <constant>yes</constant>, no password is required to
663                 connect to the printer's service. Access will be granted with the privileges of the
664                 <smbconfoption name="guest account"/>. On many systems the guest
665                 account will map to a user named <quote>nobody</quote>. This user will usually be found
666                 in the UNIX passwd file with an empty password, but with no valid UNIX login. (On some
667                 systems the guest account might not have the privilege to be able to print. Test this
668                 by logging in as your guest user using <command>su - guest</command> and run a system
669                 print command like:
670                 </para>
671         
672                 <para>
673                 <userinput>lpr -P printername /etc/motd</userinput>
674                 </para></listitem>
675         </varlistentry>
677         <varlistentry><term><smbconfoption name="public">yes </smbconfoption></term>
678                 <listitem><para>
679                 Is a synonym for <smbconfoption name="guest ok">yes</smbconfoption>.
680                 Since we have <smbconfoption name="guest ok">yes</smbconfoption>, it
681                 really does not need to be here. (This leads to the interesting question: <quote>What if I
682                 by accident have two contradictory settings for the same share?</quote> The answer is the
683                 last one encountered by Samba wins. Testparm does not complain about different settings
684                 of the same parameter for the same share. You can test this by setting up multiple
685                 lines for the <parameter>guest account</parameter> parameter with different usernames,
686                 and then run testparm to see which one is actually used by Samba.)
687                 </para></listitem>
688         </varlistentry>
690         <varlistentry><term><smbconfoption name="read only">yes </smbconfoption></term>
691                 <listitem><para>
692                 Normally (for other types of shares) prevents users from creating or modifying files
693                 in the service's directory. However, in a <quote>printable</quote> service, it is
694                 <emphasis>always</emphasis> allowed to write to the directory (if user privileges allow the
695                 connection), but only via print spooling operations. Normal write operations are not permitted.
696                 </para></listitem>
697         </varlistentry>
699         <varlistentry><term><smbconfoption name="writable">no </smbconfoption></term>
700                 <listitem><para>
701                 Is a synonym for <smbconfoption name="read only">yes</smbconfoption>.
702                 </para></listitem>
703         </varlistentry>
704 </variablelist>
705 </sect3>
707 <sect3>
708 <title>Any [my_printer_name] Section</title>
710 <para>
711 If a section appears in the &smb.conf; file, which when given the parameter
712 <smbconfoption name="printable">yes</smbconfoption> causes Samba to configure it
713 as a printer share. Windows 9x/Me clients may have problems with connecting or loading printer drivers
714 if the share name has more than eight characters. Do not name a printer share with a name that may conflict
715 with an existing user or file share name. On Client connection requests, Samba always tries to find file
716 shares with that name first. If it finds one, it will connect to this and will not connect
717 to a printer with the same name!
718 </para>
720 <variablelist>
721         <varlistentry><term><smbconfoption name="comment">Printer with Restricted Access </smbconfoption></term>
722                 <listitem><para>
723                 The comment says it all.
724                 </para></listitem>
725         </varlistentry>
727         <varlistentry><term><smbconfoption name="path">/var/spool/samba_my_printer </smbconfoption></term>
728                 <listitem><para>
729                 Sets the spooling area for this printer to a directory other than the default. It is not
730                 necessary to set it differently, but the option is available.
731                 </para></listitem>
732         </varlistentry>
734         <varlistentry><term><smbconfoption name="printer admin">kurt </smbconfoption></term>
735                 <listitem><para>
736                 The printer admin definition is different for this explicitly defined printer share from the general
737                 <smbconfsection name="[printers]"/> share. It is not a requirement; we
738                 did it to show that it is possible.
739                 </para></listitem>
740         </varlistentry>
742         <varlistentry><term><smbconfoption name="browseable">yes </smbconfoption></term>
743                 <listitem><para>
744                 This makes the printer browseable so the clients may conveniently find it when browsing the
745                 <guiicon>Network Neighborhood</guiicon>.
746                 </para></listitem>
747         </varlistentry>
749         <varlistentry><term><smbconfoption name="printable">yes </smbconfoption></term>
750                 <listitem><para>
751                 See <link linkend="ptrsect">The [printers] Section</link>.
752                 </para></listitem>
753         </varlistentry>
755         <varlistentry><term><smbconfoption name="writable">no </smbconfoption></term>
756                 <listitem><para>
757                 See <link linkend="ptrsect">The [printers] Section</link>.
758                 </para></listitem>
759         </varlistentry>
761         <varlistentry><term><smbconfoption name="hosts allow">10.160.50.,10.160.51. </smbconfoption></term>
762                 <listitem><para>
763                 Here we exercise a certain degree of access control by using the <smbconfoption name="hosts allow"/> and <smbconfoption name="hosts deny"/>
764                 parameters. This is not by any means a safe bet. It is not a way to secure your
765                 printers. This line accepts all clients from a certain subnet in a first evaluation of
766                 access control.
767                 </para></listitem>
768         </varlistentry>
770         <varlistentry><term><smbconfoption name="hosts deny">turbo_xp,10.160.50.23,10.160.51.60 </smbconfoption></term>
771                 <listitem><para>
772                 All listed hosts are not allowed here (even if they belong to the allowed subnets). As
773                 you can see, you could name IP addresses as well as NetBIOS hostnames here.
774                 </para></listitem>
775         </varlistentry>
777         <varlistentry><term><smbconfoption name="guest ok">no </smbconfoption></term>
778                 <listitem><para>
779                 This printer is not open for the guest account.
780                 </para></listitem>
781         </varlistentry>
782 </variablelist>
783 </sect3>
785 <sect3>
786 <title>Print Commands</title>
788 <para>
789 In each section defining a printer (or in the <smbconfsection name="[printers]"/> section),
790 a <parameter>print command</parameter> parameter may be defined. It sets a command to process the files
791 that have been placed into the Samba print spool directory for that printer. (That spool directory was,
792 if you remember, set up with the <smbconfoption name="path"/> parameter). Typically,
793 this command will submit the spool file to the Samba host's print subsystem, using the suitable system
794 print command. But there is no requirement that this needs to be the case. For debugging or
795 some other reason, you may want to do something completely different than print the file. An example is a
796 command that just copies the print file to a temporary location for further investigation when you need
797 to debug printing. If you craft your own print commands (or even develop print command shell scripts),
798 make sure you pay attention to the need to remove the files from the Samba spool directory. Otherwise,
799 your hard disk may soon suffer from shortage of free space.
800 </para>
801 </sect3>
803 <sect3>
804 <title>Default UNIX System Printing Commands</title>
806 <para>
807 You learned earlier on that Samba, in most cases, uses its built-in settings for many parameters
808 if it cannot find an explicitly stated one in its configuration file. The same is true for the
809 <smbconfoption name="print command"/>. The default print command varies depending
810 on the <smbconfoption name="printing"/> parameter setting. In the commands listed
811 below, you will notice some parameters of the form <emphasis>%X</emphasis> where <emphasis>X</emphasis> is
812 <emphasis>p, s, J</emphasis>, and so on. These letters stand for printer name, spool-file and job ID, respectively.
813 They are explained in more detail further below. <link linkend="printOptions">Next table</link> presents an overview of key
814 printing options but excludes the special case of CUPS that is discussed in <link linkend="CUPS-printing">CUPS Printing Support</link>.
815 </para>
817 <table frame='all' id="printOptions">
818         <title>Default Printing Settings</title>
819         <tgroup cols='2' align='left' colsep='1' rowsep='1'>
820                 <colspec align="left"/>
821                 <colspec align="left"/>
822         <thead>
823                 <row>
824                 <entry>Setting</entry>
825                 <entry>Default Printing Commands</entry>
826                 </row>
827         </thead>
828         <tbody>
829                 <row>
830                 <entry><smbconfoption name="printing">bsd|aix|lprng|plp</smbconfoption></entry>
831                 <entry>print command is <command>lpr -r -P%p %s</command></entry>
832                 </row>
833                 <row>
834                 <entry><smbconfoption name="printing">sysv|hpux</smbconfoption></entry>
835                 <entry>print command is <command>lp -c -P%p %s; rm %s</command></entry>
836                 </row>
837                 <row>
838                 <entry> <smbconfoption name="printing">qnx</smbconfoption></entry>
839                 <entry>print command is <command>lp -r -P%p -s %s</command></entry>
840                 </row>
841                 <row>
842                 <entry><smbconfoption name="printing">bsd|aix|lprng|plp</smbconfoption></entry>
843                 <entry>lpq command is <command>lpq -P%p</command></entry>
844                 </row>
845                 <row>
846                 <entry><smbconfoption name="printing">sysv|hpux</smbconfoption></entry>
847                 <entry>lpq command is <command>lpstat -o%p</command></entry>
848                 </row>
849                 <row>
850                 <entry><smbconfoption name="printing">qnx</smbconfoption></entry>
851                 <entry>lpq command is <command>lpq -P%p</command></entry>
852                 </row>
853                 <row>
854                 <entry><smbconfoption name="printing">bsd|aix|lprng|plp</smbconfoption></entry>
855                 <entry>lprm command is <command>lprm -P%p %j</command></entry>
856                 </row>
857                 <row>
858                 <entry><smbconfoption name="printing">sysv|hpux</smbconfoption></entry>
859                 <entry>lprm command is <command>cancel %p-%j</command></entry>
860                 </row>
861                 <row>
862                 <entry><smbconfoption name="printing">qnx</smbconfoption></entry>
863                 <entry>lprm command is <command>cancel %p-%j</command></entry>
864                 </row>
865                 <row>
866                 <entry><smbconfoption name="printing">bsd|aix|lprng|plp</smbconfoption></entry>
867                 <entry>lppause command is <command>lp -i %p-%j -H hold</command></entry>
868                 </row>
869                 <row>
870                 <entry><smbconfoption name="printing">sysv|hpux</smbconfoption></entry>
871                 <entry>lppause command   (...is empty)</entry>
872                 </row>
873                 <row>
874                 <entry><smbconfoption name="printing">qnx</smbconfoption></entry>
875                 <entry>lppause command   (...is empty)</entry>
876                 </row>
877                 <row>
878                 <entry><smbconfoption name="printing">bsd|aix|lprng|plp</smbconfoption></entry>
879                 <entry>lpresume command is <command>lp -i %p-%j -H resume</command></entry>
880                 </row>
881                 <row>
882                 <entry><smbconfoption name="printing">sysv|hpux</smbconfoption></entry>
883                 <entry>lpresume command   (...is empty)</entry>
884                 </row>
885                 <row>
886                 <entry><smbconfoption name="printing">qnx</smbconfoption></entry>
887                 <entry>lpresume command   (...is empty)</entry>
888                 </row>
889         </tbody>
890         </tgroup>
891 </table>
893 <para>
894 We excluded the special case of CUPS here, because it is discussed in the next chapter. For
895 <parameter>printing = CUPS</parameter>, if Samba is compiled against libcups, it uses the CUPS API to submit
896 jobs. (It is a good idea also to set <smbconfoption name="printcap">cups</smbconfoption>
897 in case your <filename>cupsd.conf</filename> is set to write its auto-generated printcap file to an
898 unusual place). Otherwise, Samba maps to the System V printing commands with the -oraw option for printing,
899 i.e., it uses <command>lp -c -d%p -oraw; rm %s</command>. With <parameter>printing = cups</parameter>,
900 and if Samba is compiled against libcups, any manually set print command will be ignored!
901 </para>
903 </sect3>
905 <sect3>
906 <title>Custom Print Commands</title>
908 <para>
909 After a print job has finished spooling to a service, the <smbconfoption name="print command"/>
910  will be used by Samba via a <emphasis>system()</emphasis> call to process the
911 spool file. Usually the command specified will submit the spool file to the host's printing subsystem. But
912 there is no requirement at all that this must be the case. The print subsystem may not remove the spool
913 file on its own. So whatever command you specify, you should ensure that the spool file is deleted after
914 it has been processed.
915 </para>
917 <para>
918 There is no difficulty with using your own customized print commands with the traditional printing
919 systems. However, if you do not wish to roll your own, you should be well informed about the default
920 built-in commands that Samba uses for each printing subsystem (see
921 Table 17.1). In all the
922 commands listed in the last paragraphs, you see parameters of the form <emphasis>%X</emphasis>. These are
923 <emphasis>macros</emphasis>, or shortcuts, used as place-holders for the names of real objects. At the time
924 of running a command with such a placeholder, Samba will insert the appropriate value automatically. Print
925 commands can handle all Samba macro substitutions. In regard to printing, the following ones do have
926 special relevance:
927 </para>
929 <itemizedlist>
930         <listitem><para><parameter>%s, %f</parameter> &smbmdash; the path to the spool file name.</para></listitem>
931         <listitem><para><parameter>%p</parameter> &smbmdash; the appropriate printer name.</para></listitem>
932         <listitem><para><parameter>%J</parameter> &smbmdash; the job name as transmitted by the client.</para></listitem>
933         <listitem><para><parameter>%c</parameter> &smbmdash; the number of printed pages of the spooled job (if known).</para></listitem>
934         <listitem><para><parameter>%z</parameter> &smbmdash; the size of the spooled print job (in bytes).</para></listitem>
935 </itemizedlist>
937 <para>
938 The print command must contain at least one occurrence of <parameter>%s</parameter> or
939 the <parameter>%f</parameter>. The <parameter>%p</parameter> is optional. If no printer name is supplied,
940 the <parameter>%p</parameter> will be silently removed from the print command. In this case, the job is
941 sent to the default printer.
942 </para>
944 <para>
945 If specified in the <smbconfsection name="[global]"/> section, the print command given will be
946 used for any printable service that does not have its own print command specified. If there is neither a
947 specified print command for a printable service nor a global print command, spool files will be created
948 but not processed! Most importantly, print files will not be removed, so they will consume disk space.
949 </para>
951 <para>
952 Printing may fail on some UNIX systems when using the <quote>nobody</quote> account. If this happens, create an
953 alternative guest account and give it the privilege to print. Set up this guest account in the
954 <smbconfsection name="[global]"/> section with the <parameter>guest account</parameter> parameter.
955 </para>
957 <para>
958 You can form quite complex print commands. You need to realize that print commands are just
959 passed to a UNIX shell. The shell is able to expand the included environment variables as
960 usual. (The syntax to include a UNIX environment variable <parameter>$variable</parameter>
961 in the Samba print command is <parameter>%$variable</parameter>.) To give you a working
962 <smbconfoption name="print command"/> example, the following will log a print job
963 to <filename>/tmp/print.log</filename>, print the file, then remove it. The semicolon (<quote>;</quote>
964 is the usual separator for commands in shell scripts:
965 </para>
967 <para><smbconfblock>
968         <smbconfoption name="print command">echo Printing %s &gt;&gt; /tmp/print.log; lpr -P %p %s; rm %s</smbconfoption>
969 </smbconfblock></para>
971 <para>
972 You may have to vary your own command considerably from this example depending on how you normally print
973 files on your system. The default for the <smbconfoption name="print command"/>
974 parameter varies depending on the setting of the <smbconfoption name="printing"/>
975 parameter. Another example is:
976 </para>
978 <para><smbconfblock>
979 <smbconfoption name="print command">/usr/local/samba/bin/myprintscript %p %s</smbconfoption>
980 </smbconfblock></para>
981 </sect3>
982 </sect2>
983 </sect1>
985 <sect1>
986 <title>Printing Developments Since Samba-2.2</title>
988 <para>
989 Prior to Samba-2.2.x, print server support for Windows clients was limited to <emphasis>LanMan</emphasis>
990 printing calls. This is the same protocol level as Windows 9x/Me PCs offer when they share printers.
991 Beginning with the 2.2.0 release, Samba started to support the native Windows NT printing mechanisms. These
992 are implemented via <emphasis>MS-RPC</emphasis> (RPC = <emphasis>Remote Procedure Calls</emphasis>
993 ). MS-RPCs use the <emphasis>SPOOLSS</emphasis> named pipe for all printing.
994 </para>
996 <para>
997 The additional functionality provided by the new SPOOLSS support includes:
998 </para>
1000 <itemizedlist>
1001         <listitem><para>
1002         Support for downloading printer driver files to Windows 95/98/NT/2000 clients upon
1003         demand (<emphasis>Point'n'Print</emphasis>).
1004         </para></listitem>
1006         <listitem><para>
1007         Uploading of printer drivers via the Windows NT <emphasis>Add Printer Wizard</emphasis> (APW)
1008         or the <ulink url="http://imprints.sourceforge.net/">Imprints</ulink> tool set.
1009         </para></listitem>
1011         <listitem><para>
1012         Support for the native MS-RPC printing calls such as
1013         StartDocPrinter, EnumJobs(), and so on. (See the
1014         <ulink url="http://msdn.microsoft.com/">MSDN documentation</ulink> for more information on the
1015         Win32 printing API).
1016         </para></listitem>
1018         <listitem><para>
1019         Support for NT <emphasis>Access Control Lists</emphasis> (ACL) on printer objects.
1020         </para></listitem>
1022         <listitem><para>
1023         Improved support for printer queue manipulation through the use of internal databases for spooled
1024         job information (implemented by various <filename>*.tdb</filename> files).
1025         </para></listitem>
1026 </itemizedlist>
1028 <para>
1029 A benefit of updating is that Samba-3 is able to publish its printers to Active Directory (or LDAP).
1030 </para>
1032 <para>
1033 A fundamental difference exists between MS Windows NT print servers and Samba operation. Windows NT
1034 permits the installation of local printers that are not shared. This is an artifact of the fact that
1035 any Windows NT machine (server or client) may be used by a user as a workstation. Samba will publish all
1036 printers that are made available, either by default or by specific declaration via printer-specific shares.
1037 </para>
1039 <para>
1040 Windows NT/200x/XP Professional clients do not have to use the standard SMB printer share; they can
1041 print directly to any printer on another Windows NT host using MS-RPC. This, of course, assumes that
1042 the client has the necessary privileges on the remote host that serves the printer resource. The
1043 default permissions assigned by Windows NT to a printer gives the Print permissions to the well-known
1044 <emphasis>Everyone</emphasis> group. (The older clients of type Windows 9x/Me can only print to shared
1045 printers).
1046 </para>
1048 <sect2>
1049 <title>Point'n'Print Client Drivers on Samba Servers</title>
1051 <para>
1052 There is much confusion about what all this means. The question is often asked, <quote>Is it or is
1053 it not necessary for printer drivers to be installed on a Samba host in order to support printing from
1054 Windows clients?</quote> The answer to this is no, it is not necessary.
1055 </para>
1057 <para>
1058 Windows NT/2000 clients can, of course, also run their APW to install drivers <emphasis>locally</emphasis>
1059 (which then connect to a Samba-served print queue). This is the same method used by Windows 9x/Me
1060 clients. (However, a <emphasis>bug</emphasis> existed in Samba 2.2.0 that made Windows NT/2000 clients
1061 require that the Samba server possess a valid driver for the printer. This was fixed in Samba 2.2.1).
1062 </para>
1064 <para>
1065 But it is a new capability to install the printer drivers into the <smbconfsection name="[print$]"/>
1066 share of the Samba server, and a big convenience, too. Then <emphasis>all</emphasis> clients
1067 (including 95/98/ME) get the driver installed when they first connect to this printer share. The
1068 <emphasis>uploading</emphasis> or <emphasis>depositing</emphasis> of the driver into this
1069 <smbconfsection name="[print$]"/> share and the following binding of this driver to an existing
1070 Samba printer share can be achieved by different means:
1071 </para>
1073 <itemizedlist>
1074         <listitem><para>
1075         Running the <emphasis>APW</emphasis> on an NT/200x/XP Professional client (this does not work from 95/98/ME clients).
1076         </para></listitem>
1078         <listitem><para>
1079         Using the <emphasis>Imprints</emphasis> tool-set.
1080         </para></listitem>
1082         <listitem><para>
1083         Using the <emphasis>smbclient</emphasis> and <emphasis>rpcclient</emphasis> command-line tools.
1084         </para></listitem>
1086         <listitem><para>
1087         Using <emphasis>cupsaddsmb</emphasis> (only works for the CUPS
1088         printing system, not for LPR/LPD, LPRng, and so on).
1089         </para></listitem>
1090 </itemizedlist>
1092 <para>
1093 Samba does not use these uploaded drivers in any way to process spooled files. These drivers are utilized
1094 entirely by the clients who download and install them via the <quote>Point'n'Print</quote> mechanism
1095 supported by Samba. The clients use these drivers to generate print files in the format the printer
1096 (or the UNIX print system) requires. Print files received by Samba are handed over to the UNIX printing
1097 system, which is responsible for all further processing, as needed.
1098 </para>
1099 </sect2>
1101 <sect2>
1102 <title>The Obsoleted [printer$] Section</title>
1104         <para>
1105         Versions of Samba prior to 2.2 made it possible to use a share named
1106         <parameter>[printer$]</parameter>. This name was taken from the same named service created by
1107         Windows 9x/Me clients when a printer was shared by them. Windows 9x/Me printer servers always
1108         have a <smbconfsection name="[printer$]"/> service that provides read-only access (with
1109         no password required) to support printer driver downloads. However, Samba's initial
1110         implementation allowed for a parameter named <parameter>printer driver location</parameter> to
1111         be used on a per share basis. This specified the location of the driver files associated with
1112         that printer. Another parameter named <parameter>printer driver</parameter> provided a means of
1113         defining the printer driver name to be sent to the client.
1114         </para>
1116         <para>
1117         These parameters, including the <parameter>printer driver file</parameter> parameter,
1118         are now removed and cannot be used in installations of Samba-3. The share name
1119         <smbconfsection name="[print$]"/> is now used for the location of download-able printer
1120         drivers. It is taken from the <smbconfsection name="[print$]"/> service created
1121         by Windows NT PCs when a printer is shared by them. Windows NT print servers always have a
1122         <smbconfsection name="[print$]"/> service that provides read-write access (in the context
1123         of its ACLs) to support printer driver downloads and uploads. This does not mean Windows
1124         9x/Me clients are now thrown aside. They can use Samba's <smbconfsection name="[print$]"/>
1125         share support just fine.
1126         </para>
1127 </sect2>
1129 <sect2>
1130 <title>Creating the [print$] Share</title>
1132 <para>
1133 In order to support the uploading and downloading of printer driver files, you must first configure a
1134 file share named <smbconfsection name="[print$]"/>. The public name of this share is hard coded
1135 in the MS Windows clients. It cannot be renamed since Windows clients are programmed to search for a
1136 service of exactly this name if they want to retrieve printer driver files.
1137 </para>
1139 <para>
1140 You should modify the server's file to add the global parameters and create the
1141 <smbconfsection name="[print$]"/> file share (of course, some of the parameter values, such
1142 as <smbconfoption name="path"/> are arbitrary and should be replaced with appropriate values for your
1143 site). See <link linkend="prtdollar">next example</link>.
1144 </para>
1146 <example id="prtdollar">
1147 <title>[print\$] example</title>
1148 <smbconfblock>
1149 <smbconfsection name="[global]"/>
1150 <smbconfcomment>members of the ntadmin group should be able to add drivers and set</smbconfcomment>
1151 <smbconfcomment>printer properties. root is implicitly always a 'printer admin'.</smbconfcomment>
1152 <smbconfoption name="printer admin">@ntadmin</smbconfoption>
1153 <member>...</member>
1154 <smbconfsection name="[printers]"/>
1155 <member>...</member>
1156 <smbconfsection name="[print$]"/>
1157 <smbconfoption name="comment">Printer Driver Download Area</smbconfoption>
1158 <smbconfoption name="path">/etc/samba/drivers</smbconfoption>
1159 <smbconfoption name="browseable">yes</smbconfoption>
1160 <smbconfoption name="guest ok">yes</smbconfoption>
1161 <smbconfoption name="read only">yes</smbconfoption>
1162 <smbconfoption name="write list">@ntadmin, root</smbconfoption>
1163 </smbconfblock>
1164 </example>
1166 <para>
1167 Of course, you also need to ensure that the directory named by the
1168 <smbconfoption name="path"/> parameter exists on the UNIX file system.
1169 </para>
1171 </sect2>
1173 <sect2>
1174 <title>[print$] Section Parameters</title>
1176 <para>
1177 The <smbconfsection name="[print$]"/> is a special section in &smb.conf;. It contains settings relevant to
1178 potential printer driver download and is used by windows clients for local print driver installation.
1179 The following parameters are frequently needed in this share section:
1180 </para>
1182 <variablelist>
1183         <varlistentry><term><smbconfoption name="comment">Printer Driver Download Area </smbconfoption></term>
1184                 <listitem><para>
1185                 The comment appears next to the share name if it is listed in a share list (usually Windows
1186                 clients will not see it, but it will also appear up in a <command>smbclient -L sambaserver
1187                 </command> output).
1188                 </para></listitem>
1189         </varlistentry>
1191         <varlistentry><term><smbconfoption name="path">/etc/samba/printers </smbconfoption></term>
1192                 <listitem><para>
1193                 Is the path to the location of the Windows driver file deposit from the UNIX point of view.
1194                 </para></listitem>
1195         </varlistentry>
1197         <varlistentry><term><smbconfoption name="browseable">no </smbconfoption></term>
1198                 <listitem><para>
1199                 Makes the <smbconfsection name="[print$]"/> share invisible to clients from the
1200                 <guimenu>Network Neighborhood</guimenu>. However, you can still mount it from any client
1201                 using the <command>net use g:\\sambaserver\print$</command> command in a DOS-box or the
1202                 <guimenu>Connect network drive menu></guimenu> from Windows Explorer.
1203                 </para></listitem>
1204         </varlistentry>
1206         <varlistentry><term><smbconfoption name="guest ok">yes </smbconfoption></term>
1207                 <listitem><para>
1208                 Gives read-only access to this share for all guest users. Access may be granted to
1209                 download and install printer drivers on clients. The requirement for <parameter>guest ok
1210                 = yes</parameter> depends on how your site is configured. If users will be guaranteed
1211                 to have an account on the Samba host, then this is a non-issue.
1212                 </para>
1214                 <note><para> 
1215                 If all your Windows NT users are guaranteed to be authenticated by the Samba server
1216                 (for example, if Samba authenticates via an NT domain server and the user has already been
1217                 validated by the Domain Controller in order to logon to the Windows NT session), then guest
1218                 access is not necessary. Of course, in a workgroup environment where you just want
1219                 to print without worrying about silly accounts and security, then configure the share for
1220                 guest access. You should consider adding <smbconfoption name="map to guest">Bad User</smbconfoption> in the <smbconfsection name="[global]"/> section
1221                 as well. Make sure you understand what this parameter does before using it.
1222                 </para></note>
1223                 </listitem>
1224         </varlistentry>
1226         <varlistentry><term><smbconfoption name="read only">yes </smbconfoption></term>
1227                 <listitem><para>
1228                 Because we do not want everybody to upload driver files (or even change driver settings),
1229                 we tagged this share as not writable.
1230                 </para></listitem>
1231         </varlistentry>
1233         <varlistentry><term><smbconfoption name="write list">@ntadmin, root </smbconfoption></term>
1234                 <listitem><para>
1235                 The <smbconfsection name="[print$]"/> was made read-only by the previous
1236                 setting so we should create a <parameter>write list</parameter> entry also. UNIX
1237                 groups (denoted with a leading <quote>@</quote> character). Users listed here are allowed
1238                 write-access (as an exception to the general public's read-only access), which they need to
1239                 update files on the share. Normally, you will want to only name administrative-level user
1240                 account in this setting. Check the file system permissions to make sure these accounts
1241                 can copy files to the share. If this is a non-root account, then the account should also
1242                 be mentioned in the global <smbconfoption name="printer admin"/>
1243                 parameter. See the &smb.conf; man page for more information on configuring file shares.
1244                 </para></listitem>
1245         </varlistentry>
1246 </variablelist>
1248 </sect2>
1250 <sect2>
1251 <title>The [print$] Share Directory</title>
1253 <para>
1254 In order for a Windows NT print server to support the downloading of driver files by multiple client
1255 architectures, you must create several subdirectories within the <smbconfsection name="[print$]"/>
1256 service (i.e., the UNIX directory named by the <smbconfoption name="path"/>
1257 parameter). These correspond to each of the supported client architectures. Samba follows this model as
1258 well. Just like the name of the <smbconfsection name="[print$]"/> share itself, the subdirectories
1259 must be exactly the names listed below (you may leave out the subdirectories of architectures you do
1260 not need to support).
1261 </para>
1263 <para>
1264 Therefore, create a directory tree below the
1265 <smbconfsection name="[print$]"/> share for each architecture you wish
1266 to support like this:
1267 </para>
1269 <para><programlisting>
1270 [print$]--+
1271           |--W32X86           # serves drivers to Windows NT x86
1272           |--WIN40            # serves drivers to Windows 95/98
1273           |--W32ALPHA         # serves drivers to Windows NT Alpha_AXP
1274           |--W32MIPS          # serves drivers to Windows NT R4000
1275           |--W32PPC           # serves drivers to Windows NT PowerPC
1276 </programlisting>
1277 </para>
1279 <important><title>Required permissions</title>
1280         <para>
1281         In order to add a new driver to your Samba host, one of two conditions must hold true:
1282         </para>
1284         <itemizedlist>
1285                 <listitem><para>
1286                 The account used to connect to the Samba host must have a UID of 0 (i.e., a root account).
1287                 </para></listitem>
1289                 <listitem><para>
1290                 The account used to connect to the Samba host must be named in the <emphasis>printer admin</emphasis>list.
1291                 </para></listitem>
1292         </itemizedlist>
1294         <para>
1295         Of course, the connected account must still have write access to add files to the subdirectories beneath
1296         <smbconfsection name="[print$]"/>. Remember that all file shares are set to <quote>read-only</quote> by default.
1297         </para>
1298 </important>
1300 <para>
1301 Once you have created the required <smbconfsection name="[print$]"/> service and
1302 associated subdirectories, go to a Windows NT 4.0/200x/XP client workstation. Open <guiicon>Network
1303 Neighborhood</guiicon> or <guiicon>My Network Places</guiicon> and browse for the Samba host. Once you
1304 have located the server, navigate to its <guiicon>Printers and Faxes</guiicon> folder. You should see
1305 an initial listing of printers that matches the printer shares defined on your Samba host.
1306 </para>
1307 </sect2>
1308 </sect1>
1310 <sect1>
1311 <title>Installing Drivers into [print$]</title>
1313 <para>
1314 Have you successfully created the <smbconfsection name="[print$]"/> share in &smb.conf;, and have your forced Samba
1315 to re-read its &smb.conf; file? Good. But you are not yet ready to use the new facility. The client driver
1316 files need to be installed into this share. So far it is still an empty share. Unfortunately, it is
1317 not enough to just copy the driver files over. They need to be
1318 correctly installed so that appropriate
1319 records for each driver will exist in the Samba internal databases so it can provide the correct
1320 drivers as they are requested from MS Windows clients. And that is a bit tricky, to say the least. We
1321 now discuss two alternative ways to install the drivers into <smbconfsection name="[print$]"/>:
1322 </para>
1324 <itemizedlist>
1325         <listitem><para>
1326         Using the Samba command-line utility <command>rpcclient</command> with its various subcommands (here:
1327         <command>adddriver</command> and <command>setdriver</command>) from any UNIX workstation.
1328         </para></listitem>
1330         <listitem><para>
1331         Running a GUI (<guiicon>Printer Properties</guiicon> and <guiicon>Add Printer Wizard</guiicon>)
1332         from any Windows NT/200x/XP client workstation.
1333         </para></listitem>
1334 </itemizedlist>
1336 <para>
1337 The latter option is probably the easier one (even if the process may seem a little bit weird at first).
1338 </para>
1340 <sect2>
1341 <title>Add Printer Wizard Driver Installation</title>
1343 <para>
1344 The initial listing of printers in the Samba host's <guiicon>Printers</guiicon> folder accessed from a
1345 client's Explorer will have no real printer driver assigned to them. By default this driver name is set
1346 to a null string. This must be changed now. The local <guiicon>Add Printer Wizard</guiicon> (APW), run from
1347 NT/2000/XP clients, will help us in this task.
1348 </para>
1350 <para>
1351 Installation of a valid printer driver is not straightforward. You must attempt
1352 to view the printer properties for the printer to which you want the driver assigned. Open the Windows
1353 Explorer, open <guiicon>Network Neighborhood</guiicon>, browse to the Samba host, open Samba's <guiicon>Printers</guiicon>
1354 folder, right-click on the printer icon and select <guimenu>Properties...</guimenu>. You are now trying to
1355 view printer and driver properties for a queue that has this default <constant>NULL</constant> driver
1356 assigned. This will result in the following error message:
1357 </para>
1359         <para><errorname>
1360         Device settings cannot be displayed. The driver for the specified printer is not installed,
1361         only spooler properties will be displayed. Do you want to install the driver now?
1362         </errorname></para>
1364 <para>
1365 Do not click on <guibutton>Yes</guibutton>!  Instead, click on <guibutton>No</guibutton> in the error dialog.
1366 Only now you will be presented with the printer properties window. From here, the way to assign a driver
1367 to a printer is open to us. You now have the choice of:
1368 </para>
1370 <itemizedlist>
1371         <listitem><para>
1372         Select a driver from the pop-up list of installed drivers. Initially this list will be empty.
1373         </para></listitem>
1375         <listitem><para>
1376         Click on <guibutton>New Driver</guibutton> to install a new printer driver (which will
1377         start up the APW).
1378         </para></listitem>
1379 </itemizedlist>
1381 <para>
1382 Once the APW is started, the procedure is exactly the same as the one you are familiar with in Windows (we
1383 assume here that you are familiar with the printer driver installations procedure on Windows NT). Make sure
1384 your connection is, in fact, setup as a user with <smbconfoption name="printer admin"/>
1385 privileges (if in doubt, use <command>smbstatus</command> to check for this). If you wish to install
1386 printer drivers for client operating systems other than <application>Windows NT x86</application>,
1387 you will need to use the <guilabel>Sharing</guilabel> tab of the printer properties dialog.
1388 </para>
1390 <para>
1391 Assuming you have connected with an administrative (or root) account (as named by the
1392 <smbconfoption name="printer admin"/> parameter), you will also be able to modify
1393 other printer properties such as ACLs and default device settings using this dialog. For the default
1394 device settings, please consider the advice given further in <link linkend="inst-rpc">Installing Print Drivers Using <command>rpcclient</command></link>.
1395 </para>
1396 </sect2>
1398 <sect2 id="inst-rpc">
1399 <title>Installing Print Drivers Using <command>rpcclient</command></title>
1401 <para>
1402 The second way to install printer drivers into <smbconfsection name="[print$]"/> and set them
1403 up in a valid way is to do it from the UNIX command line. This involves four distinct steps:
1404 </para>
1406 <orderedlist>
1407         <listitem><para>
1408         Gather info about required driver files and collect the files.
1409         </para></listitem>
1411         <listitem><para>
1412         Deposit the driver files into the <smbconfsection name="[print$]"/> share's correct subdirectories
1413         (possibly by using <command>smbclient</command>).
1414         </para></listitem>
1416         <listitem><para>
1417         Run the <command>rpcclient</command> command line utility once with the <command>adddriver</command>
1418         subcommand.
1419         </para></listitem>
1421         <listitem><para>
1422         Run <command>rpcclient</command> a second time with the <command>setdriver</command> subcommand.
1423         </para></listitem>
1424 </orderedlist>
1426 <para>
1427 We provide detailed hints for each of these steps in the paragraphs that follow.
1428 </para>
1430 <sect3>
1431 <title>Identifying Driver Files</title>
1433 <para>
1434 To find out about the driver files, you have two options. You could check the contents of the driver
1435 CDROM that came with your printer. Study the <filename>*.inf</filename> files lcoated on the CDROM. This
1436 may not be possible, since the <filename>*.inf</filename> file might be missing. Unfortunately, vendors have now started
1437 to use their own installation programs. These installations packages are often in some Windows platform
1438 archive format. Additionally, the files may be re-named during the installation process. This makes it
1439 extremely difficult to identify the driver files required.
1440 </para>
1442 <para>
1443 Then you only have the second option. Install the driver locally on a Windows client and
1444 investigate which file names and paths it uses after they are installed. (You need to repeat
1445 this procedure for every client platform you want to support. We show it here for the
1446 <application>W32X86</application> platform only, a name used by Microsoft for all Windows NT/200x/XP
1447 clients.)
1448 </para>
1450 <para>
1451 A good method to recognize the driver files is to print the test page from the driver's
1452 <guilabel>Properties</guilabel> dialog (<guilabel>General</guilabel> tab). Then look at the list of
1453 driver files named on the printout. You'll need to recognize what Windows (and Samba) are calling the
1454 <guilabel>Driver File</guilabel>, <guilabel>Data File</guilabel>, <guilabel>Config File</guilabel>,
1455 <guilabel>Help File</guilabel> and (optionally) the <guilabel>Dependent Driver Files</guilabel>
1456 (this may vary slightly for Windows NT). You need to take a note of all file names for the next steps.
1457 </para>
1459 <para>
1460 Another method to quickly test the driver filenames and related paths is provided by the
1461 <command>rpcclient</command> utility. Run it with <command>enumdrivers</command> or with the
1462 <command>getdriver</command> subcommand, each at the <filename>3</filename> info level. In the following example,
1463 <emphasis>TURBO_XP</emphasis> is the name of the Windows PC (in this case it was a Windows XP Professional
1464 laptop). I installed the driver locally to TURBO_XP, from a Samba server called <constant>KDE-BITSHOP</constant>.
1465 We could run an interactive <command>rpcclient</command> session; then we would get an
1466 <command>rpcclient /></command> prompt and would type the subcommands at this prompt. This is left as
1467 a good exercise to the reader. For now, we use <command>rpcclient</command> with the <option>-c</option>
1468 parameter to execute a single subcommand line and exit again. This is the method you would use if you
1469 want to create scripts to automate the procedure for a large number of printers and drivers. Note the
1470 different quotes used to overcome the different spaces in between words:
1471 </para>
1473 <para><screen>
1474 &rootprompt;<userinput>rpcclient -U'Danka%xxxx' -c \
1475         'getdriver "Heidelberg Digimaster 9110 (PS)" 3' TURBO_XP</userinput>
1476 cmd = getdriver "Heidelberg Digimaster 9110 (PS)" 3
1478 [Windows NT x86]
1479 Printer Driver Info 3:
1480   Version: [2]
1481   Driver Name: [Heidelberg Digimaster 9110 (PS)]
1482   Architecture: [Windows NT x86]
1483   Driver Path: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01_de.DLL]
1484   Datafile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.ppd]
1485   Configfile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01U_de.DLL]
1486   Helpfile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01U_de.HLP]
1487   
1488   Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.DLL]
1489   Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.INI]
1490   Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.dat]
1491   Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.cat]
1492   Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.def]
1493   Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.hre]
1494   Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.vnd]
1495   Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.hlp]
1496   Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01Aux.dll]
1497   Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01_de.NTF]
1498   
1499   Monitorname: []
1500   Defaultdatatype: []
1501 </screen></para>
1503 <para>
1504 You may notice that this driver has quite a large number of <guilabel>Dependent files</guilabel>
1505 (there are worse cases, however). Also, strangely, the
1506 <guilabel>Driver File</guilabel> is tagged here
1507 <guilabel>Driver Path</guilabel>. We do not yet have support for the so-called
1508 <application>WIN40</application> architecture installed. This name is used by Microsoft for the Windows
1509 9x/Me platforms. If we want to support these, we need to install the Windows 9x/Me driver files in
1510 addition to those for <application>W32X86</application> (i.e., the Windows NT72000/XP clients) onto a
1511 Windows PC. This PC can also host the Windows 9x/Me drivers, even if it runs on Windows NT, 2000 or XP.
1512 </para>
1514 <para>
1515 Since the <smbconfsection name="[print$]"/> share is usually accessible through the <guiicon>Network
1516 Neighborhood</guiicon>, you can also use the UNC notation from Windows Explorer to poke at it. The Windows
1517 9x/Me driver files will end up in subdirectory <filename>0</filename> of the <filename>WIN40</filename>
1518 directory. The full path to access them will be <filename>\\WINDOWSHOST\print$\WIN40\0\</filename>.
1519 </para>
1521 <note><para>
1522 More recent drivers on Windows 2000 and Windows XP are installed into the <quote>3</quote> subdirectory
1523 instead of the <quote>2</quote>. The version 2 of drivers, as used in Windows NT, were running in Kernel
1524 Mode. Windows 2000 changed this. While it still can use the Kernel Mode drivers (if this is enabled by
1525 the Admin), its native mode for printer drivers is User Mode execution. This requires drivers designed
1526 for this. These types of drivers install into the <quote>3</quote> subdirectory.
1527 </para></note>
1528 </sect3>
1530 <sect3>
1531 <title>Obtaining Driver Files from Windows Client [print$] Shares</title>
1533 <para>
1534 Now we need to collect all the driver files we identified in our previous step. Where do we get them
1535 from? Well, why not retrieve them from the very PC and the same <smbconfsection name="[print$]"/>
1536 share that we investigated in our last step to identify the files? We can use <command>smbclient</command>
1537 to do this. We will use the paths and names that were leaked to us by <command>getdriver</command>. The
1538 listing is edited to include line breaks for readability:
1539 </para>
1541 <para><screen>
1542 &rootprompt;<userinput>smbclient //TURBO_XP/print\$ -U'Danka%xxxx' \ 
1543    -c 'cd W32X86/2;mget HD*_de.* hd*ppd Hd*_de.* Hddm*dll HDN*Aux.DLL'</userinput>
1545 added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
1546 Got a positive name query response from 10.160.50.8 ( 10.160.50.8 )
1547 Domain=[DEVELOPMENT] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
1548 <prompt>Get file Hddm91c1_de.ABD? </prompt><userinput>n</userinput>
1549 <prompt>Get file Hddm91c1_de.def? </prompt><userinput>y</userinput>
1550 getting file \W32X86\2\Hddm91c1_de.def of size 428 as Hddm91c1_de.def
1551 <prompt>Get file Hddm91c1_de.DLL? </prompt><userinput>y</userinput>
1552 getting file \W32X86\2\Hddm91c1_de.DLL of size 876544 as Hddm91c1_de.DLL
1553 [...]
1554 </screen></para>
1556 <para>
1557 After this command is complete, the files are in our current local directory. You probably have noticed
1558 that this time we passed several commands to the <option>-c</option> parameter, separated by semi-colons.
1559 This effects that all commands are executed in sequence on the remote Windows server before smbclient
1560 exits again.
1561 </para>
1563 <para>
1564 Remember to repeat the procedure for the <application>WIN40</application> architecture should
1565 you need to support Windows 9x/Me/XP clients. Remember too, the files for these architectures are in the
1566 <filename>WIN40/0/</filename> subdirectory. Once this is complete, we can run <command>smbclient ...
1567 put</command> to store the collected files on the Samba server's <smbconfsection name="[print$]"/>
1568 share.
1569 </para>
1570 </sect3>
1572 <sect3>
1573 <title>Installing Driver Files into [print$]</title>
1575 <para>
1576 We are now going to locate the driver files into the <smbconfsection name="[print$]"/>
1577 share. Remember, the UNIX path to this share has been defined
1578 previously in your words missing here. You
1579 also have created subdirectories for the different Windows client types you want to
1580 support. Supposing your <smbconfsection name="[print$]"/> share maps to the UNIX path
1581 <filename>/etc/samba/drivers/</filename>, your driver files should now go here:
1582 </para>
1584 <itemizedlist>
1585         <listitem><para>
1586         For all Windows NT, 2000 and XP clients into <filename>/etc/samba/drivers/W32X86/</filename> but
1587         not (yet) into the <filename>2</filename> subdirectory.
1588         </para></listitem>
1590         <listitem><para>
1591         For all Windows 95, 98 and ME clients into <filename>/etc/samba/drivers/WIN40/</filename> but not
1592         (yet) into the <filename>0</filename> subdirectory.
1593         </para></listitem>
1594 </itemizedlist>
1596 <para>
1597 We again use smbclient to transfer the driver files across the network. We specify the same files
1598 and paths as were leaked to us by running <command>getdriver</command> against the original
1599 <emphasis>Windows</emphasis> install. However, now we are going to store the files into a
1600 <emphasis>Samba/UNIX</emphasis> print server's <smbconfsection name="[print$]"/> share.
1601 </para>
1603 <para><screen>
1604 &rootprompt;<userinput>smbclient //SAMBA-CUPS/print\$ -U'root%xxxx' -c \
1605   'cd W32X86; put HDNIS01_de.DLL; \
1606   put Hddm91c1_de.ppd; put HDNIS01U_de.DLL;        \
1607   put HDNIS01U_de.HLP; put Hddm91c1_de.DLL;        \
1608   put Hddm91c1_de.INI; put Hddm91c1KMMin.DLL;      \
1609   put Hddm91c1_de.dat; put Hddm91c1_de.dat;        \
1610   put Hddm91c1_de.def; put Hddm91c1_de.hre;        \
1611   put Hddm91c1_de.vnd; put Hddm91c1_de.hlp;        \
1612   put Hddm91c1_de_reg.HLP; put HDNIS01Aux.dll;     \
1613   put HDNIS01_de.NTF'</userinput>
1615 added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
1616 Got a positive name query response from 10.160.51.162 ( 10.160.51.162 )
1617 Domain=[CUPS-PRINT] OS=[UNIX] Server=[Samba 2.2.7a]
1618 putting file HDNIS01_de.DLL as \W32X86\HDNIS01_de.DLL
1619 putting file Hddm91c1_de.ppd as \W32X86\Hddm91c1_de.ppd
1620 putting file HDNIS01U_de.DLL as \W32X86\HDNIS01U_de.DLL
1621 putting file HDNIS01U_de.HLP as \W32X86\HDNIS01U_de.HLP
1622 putting file Hddm91c1_de.DLL as \W32X86\Hddm91c1_de.DLL
1623 putting file Hddm91c1_de.INI as \W32X86\Hddm91c1_de.INI
1624 putting file Hddm91c1KMMin.DLL as \W32X86\Hddm91c1KMMin.DLL
1625 putting file Hddm91c1_de.dat as \W32X86\Hddm91c1_de.dat
1626 putting file Hddm91c1_de.dat as \W32X86\Hddm91c1_de.dat
1627 putting file Hddm91c1_de.def as \W32X86\Hddm91c1_de.def
1628 putting file Hddm91c1_de.hre as \W32X86\Hddm91c1_de.hre
1629 putting file Hddm91c1_de.vnd as \W32X86\Hddm91c1_de.vnd
1630 putting file Hddm91c1_de.hlp as \W32X86\Hddm91c1_de.hlp
1631 putting file Hddm91c1_de_reg.HLP as \W32X86\Hddm91c1_de_reg.HLP
1632 putting file HDNIS01Aux.dll as \W32X86\HDNIS01Aux.dll
1633 putting file HDNIS01_de.NTF as \W32X86\HDNIS01_de.NTF
1634 </screen>
1636 Whew &smbmdash; that was a lot of typing! Most drivers are a lot smaller &smbmdash; many only having three generic
1637 PostScript driver files plus one PPD. While we did retrieve the files from the <filename>2</filename>
1638 subdirectory of the <filename>W32X86</filename> directory from the Windows box, we do not put them
1639 (for now) in this same subdirectory of the Samba box. This relocation will automatically be done by the
1640 <command>adddriver</command> command, which we will run shortly (and do not forget to also put the files
1641 for the Windows 9x/Me architecture into the <filename>WIN40/</filename> subdirectory should you need them).
1642 </para>
1643 </sect3>
1645 <sect3>
1646 <title><command>smbclient</command> to Confirm Driver Installation</title>
1648 <para>
1649 For now we verify that our files are there. This can be done with <command>smbclient</command>, too
1650 (but, of course, you can log in via SSH also and do this through a standard UNIX shell access):
1651 </para>
1653 <para><screen>
1654 &rootprompt;<userinput>smbclient //SAMBA-CUPS/print\$ -U 'root%xxxx' \
1655         -c 'cd W32X86; pwd; dir; cd 2; pwd; dir'</userinput>
1656  added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
1657 Got a positive name query response from 10.160.51.162 ( 10.160.51.162 )
1658 Domain=[CUPS-PRINT] OS=[UNIX] Server=[Samba 2.2.8a]
1660 Current directory is \\SAMBA-CUPS\print$\W32X86\
1661 .                                  D        0  Sun May  4 03:56:35 2003
1662 ..                                 D        0  Thu Apr 10 23:47:40 2003
1663 2                                   D        0  Sun May  4 03:56:18 2003
1664 HDNIS01Aux.dll                      A    15356  Sun May  4 03:58:59 2003
1665 Hddm91c1KMMin.DLL                   A    46966  Sun May  4 03:58:59 2003
1666 HDNIS01_de.DLL                      A   434400  Sun May  4 03:58:59 2003
1667 HDNIS01_de.NTF                      A   790404  Sun May  4 03:56:35 2003
1668 Hddm91c1_de.DLL                     A   876544  Sun May  4 03:58:59 2003
1669 Hddm91c1_de.INI                     A      101  Sun May  4 03:58:59 2003
1670 Hddm91c1_de.dat                     A     5044  Sun May  4 03:58:59 2003
1671 Hddm91c1_de.def                     A      428  Sun May  4 03:58:59 2003
1672 Hddm91c1_de.hlp                     A    37699  Sun May  4 03:58:59 2003
1673 Hddm91c1_de.hre                     A   323584  Sun May  4 03:58:59 2003
1674 Hddm91c1_de.ppd                     A    26373  Sun May  4 03:58:59 2003
1675 Hddm91c1_de.vnd                     A    45056  Sun May  4 03:58:59 2003
1676 HDNIS01U_de.DLL                     A   165888  Sun May  4 03:58:59 2003
1677 HDNIS01U_de.HLP                     A    19770  Sun May  4 03:58:59 2003
1678 Hddm91c1_de_reg.HLP                 A   228417  Sun May  4 03:58:59 2003
1679               40976 blocks of size 262144. 709 blocks available
1681 Current directory is \\SAMBA-CUPS\print$\W32X86\2\
1682 .                                  D        0  Sun May  4 03:56:18 2003
1683 ..                                 D        0  Sun May  4 03:56:35 2003
1684 ADOBEPS5.DLL                        A   434400  Sat May  3 23:18:45 2003
1685 laserjet4.ppd                       A     9639  Thu Apr 24 01:05:32 2003
1686 ADOBEPSU.DLL                        A   109568  Sat May  3 23:18:45 2003
1687 ADOBEPSU.HLP                        A    18082  Sat May  3 23:18:45 2003
1688 PDFcreator2.PPD                     A    15746  Sun Apr 20 22:24:07 2003
1689               40976 blocks of size 262144. 709 blocks available
1690 </screen></para>
1692 <para>
1693 Notice that there are already driver files present in the <filename>2</filename> subdirectory (probably
1694 from a previous installation). Once the files for the new driver are there too, you are still a few
1695 steps away from being able to use them on the clients. The only thing you could do now is to retrieve
1696 them from a client just like you retrieve ordinary files from a file share, by opening print$ in Windows
1697 Explorer. But that wouldn't install them per Point'n'Print. The reason
1698 is: Samba does not yet know that
1699 these files are something special, namely <emphasis>printer driver files</emphasis> and it does not know
1700 to which print queue(s) these driver files belong.
1701 </para>
1702 </sect3>
1704 <sect3>
1705 <title>Running <command>rpcclient</command> with <command>adddriver</command></title>
1707 <para>
1708 Next, you must tell Samba about the special category of the files you just uploaded into the
1709 <smbconfsection name="[print$]"/> share. This is done by the <command>adddriver</command>
1710 command. It will prompt Samba to register the driver files into its internal TDB database files. The
1711 following command and its output has been edited, again, for readability:
1712 </para>
1714 <para><screen>
1715 &rootprompt;<userinput>rpcclient -Uroot%xxxx -c 'adddriver "Windows NT x86" \
1716   "dm9110:HDNIS01_de.DLL: \
1717   Hddm91c1_de.ppd:HDNIS01U_de.DLL:HDNIS01U_de.HLP:   \
1718   NULL:RAW:Hddm91c1_de.DLL,Hddm91c1_de.INI,          \
1719   Hddm91c1_de.dat,Hddm91c1_de.def,Hddm91c1_de.hre,   \
1720   Hddm91c1_de.vnd,Hddm91c1_de.hlp,Hddm91c1KMMin.DLL, \
1721   HDNIS01Aux.dll,HDNIS01_de.NTF,                     \
1722   Hddm91c1_de_reg.HLP' SAMBA-CUPS</userinput>
1724 cmd = adddriver "Windows NT x86" \
1725   "dm9110:HDNIS01_de.DLL:Hddm91c1_de.ppd:HDNIS01U_de.DLL:   \
1726   HDNIS01U_de.HLP:NULL:RAW:Hddm91c1_de.DLL,Hddm91c1_de.INI, \
1727   Hddm91c1_de.dat,Hddm91c1_de.def,Hddm91c1_de.hre,          \
1728   Hddm91c1_de.vnd,Hddm91c1_de.hlp,Hddm91c1KMMin.DLL,        \
1729   HDNIS01Aux.dll,HDNIS01_de.NTF,Hddm91c1_de_reg.HLP"
1731 Printer Driver dm9110 successfully installed.
1732 </screen></para>
1734 <para>
1735 After this step, the driver should be recognized by Samba on the print server. You need to be very
1736 careful when typing the command. Don't exchange the order of the fields. Some changes would lead to
1737 an <computeroutput>NT_STATUS_UNSUCCESSFUL</computeroutput> error message. These become obvious. Other
1738 changes might install the driver files successfully, but render the driver unworkable. So take care!
1739 Hints about the syntax of the adddriver command are in the man page. The CUPS printing chapter 
1740 provides a more detailed description, should you need it.
1741 </para>
1742 </sect3>
1744 <sect3>
1745 <title>Checking <command>adddriver</command> Completion</title>
1747 <para>
1748 One indication for Samba's recognition of the files as driver files is the <computeroutput>successfully
1749 installed</computeroutput> message. Another one is the fact that our files have been moved by the
1750 <command>adddriver</command> command into the <filename>2</filename> subdirectory. You can check this
1751 again with <command>smbclient</command>:
1752 </para>
1754 <para><screen>
1755 &rootprompt;<userinput>smbclient //SAMBA-CUPS/print\$ -Uroot%xx \
1756         -c 'cd W32X86;dir;pwd;cd 2;dir;pwd'</userinput>
1757  added interface ip=10.160.51.162 bcast=10.160.51.255 nmask=255.255.252.0
1758  Domain=[CUPS-PRINT] OS=[UNIX] Server=[Samba 2.2.7a]
1760   Current directory is \\SAMBA-CUPS\print$\W32X86\
1761   .                                  D        0  Sun May  4 04:32:48 2003
1762   ..                                 D        0  Thu Apr 10 23:47:40 2003
1763   2                                   D        0  Sun May  4 04:32:48 2003
1764                 40976 blocks of size 262144. 731 blocks available 
1766   Current directory is \\SAMBA-CUPS\print$\W32X86\2\
1767   .                                  D        0  Sun May  4 04:32:48 2003
1768   ..                                 D        0  Sun May  4 04:32:48 2003
1769   DigiMaster.PPD                      A   148336  Thu Apr 24 01:07:00 2003
1770   ADOBEPS5.DLL                        A   434400  Sat May  3 23:18:45 2003
1771   laserjet4.ppd                       A     9639  Thu Apr 24 01:05:32 2003
1772   ADOBEPSU.DLL                        A   109568  Sat May  3 23:18:45 2003
1773   ADOBEPSU.HLP                        A    18082  Sat May  3 23:18:45 2003
1774   PDFcreator2.PPD                     A    15746  Sun Apr 20 22:24:07 2003
1775   HDNIS01Aux.dll                      A    15356  Sun May  4 04:32:18 2003
1776   Hddm91c1KMMin.DLL                   A    46966  Sun May  4 04:32:18 2003
1777   HDNIS01_de.DLL                      A   434400  Sun May  4 04:32:18 2003
1778   HDNIS01_de.NTF                      A   790404  Sun May  4 04:32:18 2003
1779   Hddm91c1_de.DLL                     A   876544  Sun May  4 04:32:18 2003
1780   Hddm91c1_de.INI                     A      101  Sun May  4 04:32:18 2003
1781   Hddm91c1_de.dat                     A     5044  Sun May  4 04:32:18 2003
1782   Hddm91c1_de.def                     A      428  Sun May  4 04:32:18 2003
1783   Hddm91c1_de.hlp                     A    37699  Sun May  4 04:32:18 2003
1784   Hddm91c1_de.hre                     A   323584  Sun May  4 04:32:18 2003
1785   Hddm91c1_de.ppd                     A    26373  Sun May  4 04:32:18 2003
1786   Hddm91c1_de.vnd                     A    45056  Sun May  4 04:32:18 2003
1787   HDNIS01U_de.DLL                     A   165888  Sun May  4 04:32:18 2003
1788   HDNIS01U_de.HLP                     A    19770  Sun May  4 04:32:18 2003
1789   Hddm91c1_de_reg.HLP                 A   228417  Sun May  4 04:32:18 2003
1790                 40976 blocks of size 262144. 731 blocks available
1791 </screen></para>
1793 <para>
1794 Another verification is that the timestamp of the printing TDB files is now updated
1795 (and possibly their file size has increased).
1796 </para>
1797 </sect3>
1799 <sect3>
1800 <title>Check Samba for Driver Recognition</title>
1802 <para>
1803 Now the driver should be registered with Samba. We can easily verify this, and will do so in a
1804 moment. However, this driver is not yet associated with a particular printer. We may check the driver
1805 status of the files by at least three methods:
1806 </para>
1808 <itemizedlist>
1809         <listitem><para>
1810         From any Windows client browse Network Neighborhood, find the Samba host and open the Samba
1811         <guiicon>Printers and Faxes</guiicon> folder. Select any printer icon, right-click and select
1812         the printer <guimenuitem>Properties</guimenuitem>. Click the <guilabel>Advanced</guilabel>
1813         tab. Here is a field indicating the driver for that printer. A drop-down menu allows you to
1814         change that driver (be careful not to do this unwittingly). You can use this list to view
1815         all drivers known to Samba. Your new one should be among them. (Each type of client will only
1816         see his own architecture's list. If you do not have every driver installed for each platform,
1817         the list will differ if you look at it from Windows95/98/ME or Windows NT/2000/XP.)
1818         </para></listitem>
1820         <listitem><para>
1821         From a Windows 200x/XP client (not Windows NT) browse <guiicon>Network Neighborhood</guiicon>,
1822         search for the Samba server and open the server's <guiicon>Printers</guiicon> folder,
1823         right-click on the white background (with no printer highlighted). Select <guimenuitem>Server
1824         Properties</guimenuitem>. On the <guilabel>Drivers</guilabel> tab you will see the new driver
1825         listed. This view enables you to also inspect the list of files belonging to that driver
1826         (this does not work on Windows NT, but only on Windows 2000 and Windows XP; Windows NT does not
1827         provide the <guimenuitem>Drivers</guimenuitem> tab). An
1828         alternative and much quicker method for
1829         Windows 2000/XP to start this dialog is by typing into a DOS box (you must of course adapt the
1830         name to your Samba server instead of <replaceable>SAMBA-CUPS</replaceable>):
1831         </para>
1833         <para><userinput>rundll32 printui.dll,PrintUIEntry /s /t2 /n\\<replaceable>SAMBA-CUPS</replaceable></userinput></para>
1834         </listitem>
1836         <listitem><para>
1837         From a UNIX prompt, run this command (or a variant thereof) where
1838         <replaceable>SAMBA-CUPS</replaceable> is the name of the Samba host and xxxx represents the
1839         actual Samba password assigned to root:
1840         </para>
1842         <para><userinput>rpcclient -U'root%xxxx' -c 'enumdrivers' <replaceable>SAMBA-CUPS</replaceable></userinput></para>
1844         <para>
1845         You will see a listing of all drivers Samba knows about. Your new one should be among
1846         them. But it is only listed under the <parameter>[Windows NT x86]</parameter> heading, not under
1847         <smbconfsection name="[Windows 4.0]"/>, since you didn't install that part. Or did you?
1848         You will see a listing of all drivers Samba knows about. Your new one should be among them. In
1849         our example it is named <constant>dm9110</constant>. Note that the third column shows the other
1850         installed drivers twice, one time for each supported architecture. Our new driver only shows up
1851         for <application>Windows NT 4.0 or 2000</application>. To have it present for <application>Windows
1852         95, 98 and ME</application>, you'll have to repeat the whole procedure with the WIN40 architecture
1853         and subdirectory.
1854         </para></listitem>
1855 </itemizedlist>
1856 </sect3>
1858 <sect3>
1859 <title>Specific Driver Name Flexibility</title>
1861 <para>
1862 You can name the driver as you like. If you repeat the <command>adddriver</command> step with the same
1863 files as before but with a different driver name, it will work the same:
1864 </para>
1866 <para><screen>
1867 &rootprompt;<userinput>rpcclient -Uroot%xxxx         \
1868   -c 'adddriver "Windows NT x86"                     \
1869   "mydrivername:HDNIS01_de.DLL:              \
1870   Hddm91c1_de.ppd:HDNIS01U_de.DLL:HDNIS01U_de.HLP:   \
1871   NULL:RAW:Hddm91c1_de.DLL,Hddm91c1_de.INI,          \
1872   Hddm91c1_de.dat,Hddm91c1_de.def,Hddm91c1_de.hre,   \
1873   Hddm91c1_de.vnd,Hddm91c1_de.hlp,Hddm91c1KMMin.DLL, \
1874   HDNIS01Aux.dll,HDNIS01_de.NTF,Hddm91c1_de_reg.HLP' SAMBA-CUPS
1875   </userinput>
1877 cmd = adddriver "Windows NT x86" \
1878  "mydrivername:HDNIS01_de.DLL:Hddm91c1_de.ppd:HDNIS01U_de.DLL:\
1879   HDNIS01U_de.HLP:NULL:RAW:Hddm91c1_de.DLL,Hddm91c1_de.INI,           \
1880   Hddm91c1_de.dat,Hddm91c1_de.def,Hddm91c1_de.hre,                    \
1881   Hddm91c1_de.vnd,Hddm91c1_de.hlp,Hddm91c1KMMin.DLL,                  \
1882   HDNIS01Aux.dll,HDNIS01_de.NTF,Hddm91c1_de_reg.HLP"
1884 Printer Driver mydrivername successfully installed.
1885 </screen></para>
1887 <para>
1888 You will be able to bind that driver to any print queue (however, you are responsible that
1889 you associate drivers to queues that make sense with respect to target printers). You cannot run the
1890 <command>rpcclient</command> <command>adddriver</command> command repeatedly. Each run consumes the
1891 files you had put into the <smbconfsection name="[print$]"/> share by moving them into the
1892 respective subdirectories. So you must execute an <command>smbclient ... put</command> command before
1893 each <command>rpcclient ... adddriver</command> command.
1894 </para>
1895 </sect3>
1897 <sect3>
1898 <title>Running <command>rpcclient</command> with the <command>setdriver</command></title>
1900 <para>
1901 Samba needs to know which printer owns which driver. Create a mapping of the driver to a printer, and
1902 store this info in Samba's memory, the TDB files. The <command>rpcclient setdriver</command> command
1903 achieves exactly this:
1904 </para>
1906 <para><screen>
1907 &rootprompt;<userinput>rpcclient -U'root%xxxx' -c 'setdriver dm9110 mydrivername' <replaceable>SAMBA-CUPS</replaceable></userinput>
1908  cmd = setdriver dm9110 mydrivername
1910 Successfully set dm9110 to driver mydrivername.
1911 </screen></para>
1913 <para>
1914 Ah, no, I did not want to do that. Repeat, this time with the name I intended: 
1915 </para>
1917 <para><screen>
1918 &rootprompt;<userinput>rpcclient -U'root%xxxx' -c 'setdriver dm9110 dm9110' <replaceable>SAMBA-CUPS</replaceable></userinput>
1919  cmd = setdriver dm9110 dm9110
1920 Successfully set dm9110 to driver dm9110.
1921 </screen></para>
1923 <para>
1924 The syntax of the command is:
1925 <screen>
1926 <userinput>rpcclient -U'root%<replaceable>sambapassword</replaceable>' -c 'setdriver <replaceable>printername</replaceable> \
1927  <replaceable>drivername</replaceable>' <replaceable>SAMBA-Hostname</replaceable></userinput>. 
1928 </screen>
1929 Now we have done most of the work, but not all of it.
1930 </para>
1932 <note><para>
1933 The <command>setdriver</command> command will only succeed if the
1934 printer is already known to Samba. A
1935 bug in 2.2.x prevented Samba from recognizing freshly installed printers. You had to restart Samba,
1936 or at least send an HUP signal to all running smbd processes to work around this: <userinput>kill -HUP
1937 `pidof smbd`</userinput>.
1938 </para></note>
1939 </sect3>
1940 </sect2>
1941 </sect1>
1943 <sect1>
1944 <title>Client Driver Installation Procedure</title>
1946 <para>
1947 As Don Quixote said: <quote>The proof of the pudding is in the eating.</quote> The proof
1948 for our setup lies in the printing. So let's install the printer driver onto the client PCs. This is
1949 not as straightforward as it may seem. Read on.
1950 </para>
1952 <sect2>
1953 <title>First Client Driver Installation</title>
1955 <para>
1956 Especially important is the installation onto the first client PC (for each architectural platform
1957 separately). Once this is done correctly, all further clients are easy to setup and shouldn't need further
1958 attention. What follows is a description for the recommended first procedure. You work now from a client
1959 workstation. You should guarantee that your connection is not unwittingly mapped to <emphasis>bad
1960 user</emphasis> nobody. In a DOS box type:
1961 </para>
1963 <para><userinput>net use \\<replaceable>SAMBA-SERVER</replaceable>\print$ /user:root</userinput></para>
1965 <para>
1966 Replace root, if needed, by another valid <smbconfoption name="printer admin"/> user as given in
1967 the definition. Should you already be connected as a different user, you will get an error message. There
1968 is no easy way to get rid of that connection, because Windows does not seem to know a concept of logging
1969 off from a share connection (do not confuse this with logging off from the local workstation; that is
1970 a different matter).  On Windows NT/2K, you can force a logoff from all smb/cifs connections by restarting the 
1971 <quote>workstation</quote> service. You can try to close all Windows file explorer and Internet Explorer for 
1972 Windows. As a last resort, you may have to reboot. Make sure there is no automatic reconnection set up. It may be
1973 easier to go to a different workstation and try from there. After you have made sure you are connected
1974 as a printer admin user (you can check this with the <command>smbstatus</command> command on Samba),
1975 do this from the Windows workstation:
1976 </para>
1978 <procedure>
1979         <step><para>
1980         Open <guiicon>Network Neighborhood</guiicon>.
1981         </para></step>
1983         <step><para>
1984         Browse to Samba server.
1985         </para></step>
1987         <step><para>
1988         Open its <guiicon>Printers and Faxes</guiicon> folder.
1989         </para></step>
1991         <step><para>
1992         Highlight and right-click on the printer.
1993         </para></step>
1995         <step><para>
1996         Select <guimenuitem>Connect</guimenuitem> (for Windows NT4/200x
1997         it is possibly <guimenuitem>Install</guimenuitem>).
1998         </para></step>
1999 </procedure>
2001 <para>
2002 A new printer (named <replaceable>printername</replaceable> on Samba-server) should now have
2003 appeared in your <emphasis>local</emphasis> Printer folder (check <guimenu>Start</guimenu> --
2004 <guimenuitem>Settings</guimenuitem> -- <guimenuitem>Control Panel</guimenuitem> -- <guiicon>Printers
2005 and Faxes</guiicon>).
2006 </para>
2008 <para>
2009 Most likely you are now tempted to try to print a test page. After all, you now can open the printer
2010 properties, and on the <guimenu>General</guimenu> tab there is a button offering to do just that. But
2011 chances are that you get an error message saying <errorname>Unable to print Test Page</errorname>. The
2012 reason might be that there is not yet a valid Device Mode set for the driver, or that the <quote>Printer
2013 Driver Data</quote> set is still incomplete.
2014 </para>
2016 <para>
2017 You must make sure that a valid <parameter>Device Mode</parameter> is set for the
2018 driver. We now explain what that means.
2019 </para>
2020 </sect2>
2022 <sect2>
2023 <title>Setting Device Modes on New Printers</title>
2025 <para>
2026 For a printer to be truly usable by a Windows NT/200x/XP client, it must possess:
2027 </para>
2029 <itemizedlist>
2030         <listitem><para>
2031         A valid <emphasis>Device Mode</emphasis> generated by the driver for the printer (defining things
2032         like paper size, orientation and duplex settings).
2033         </para></listitem>
2035         <listitem><para>
2036         A complete set of <emphasis>Printer Driver Data</emphasis> generated by the driver.
2037         </para></listitem>
2038 </itemizedlist>
2040 <para>
2041 If either of these is incomplete, the clients can produce less than optimal output at best. In the
2042 worst cases, unreadable garbage or nothing at all comes from the printer or it produces a harvest of
2043 error messages when attempting to print. Samba stores the named values and all printing related information in
2044 its internal TDB database files <filename>(ntprinters.tdb</filename>, <filename>ntdrivers.tdb</filename>,
2045 <filename>printing.tdb</filename> and <filename>ntforms.tdb</filename>).
2046 </para>
2048 <para>
2049 What do these two words stand for? Basically, the Device Mode and the set of Printer Driver Data is a
2050 collection of settings for all print queue properties, initialized in a sensible way. Device Modes and
2051 Printer Driver Data should initially be set on the print server (the Samba host) to healthy
2052 values so the clients can start to use them immediately. How do we set these initial healthy values?
2053 This can be achieved by accessing the drivers remotely from an NT (or 200x/XP) client, as is discussed
2054 in the following paragraphs.
2055 </para>
2057 <para>
2058 Be aware that a valid Device Mode can only be initiated by a
2059 <smbconfoption name="printer admin"/>, or root
2060 (the reason should be obvious). Device Modes can only be correctly
2061 set by executing the printer driver program itself. Since Samba cannot execute this Win32 platform driver
2062 code, it sets this field initially to NULL (which is not a valid setting for clients to use). Fortunately,
2063 most drivers automatically generate the Printer Driver Data that is needed when they are uploaded to the
2064 <smbconfsection name="[print$]"/> share with the help of the APW or rpcclient.
2065 </para>
2067 <para>
2068 The generation and setting of a first valid Device Mode, however, requires some tickling from a client,
2069 to set it on the Samba server. The easiest means of doing so is to simply change the page orientation on
2070 the server's printer. This executes enough of the printer driver program on the client for the desired
2071 effect to happen, and feeds back the new Device Mode to our Samba server. You can use the native Windows
2072 NT/200x/XP printer properties page from a Window client for this:
2073 </para>
2075 <procedure>
2076         <step><para>
2077         Browse the <guiicon>Network Neighborhood.</guiicon>
2078         </para></step>
2080         <step><para>
2081         Find the Samba server.
2082         </para></step>
2084         <step><para>
2085         Open the Samba server's <guiicon>Printers and Faxes</guiicon> folder.
2086         </para></step>
2088         <step><para>
2089         Highlight the shared printer in question.
2090         </para></step>
2092         <step><para>
2093         Right-click on the printer (you may already be here, if you followed the last section's description).
2094         </para></step>
2096         <step><para>
2097         At the bottom of the context menu select <guimenu>Properties</guimenu> (if the menu still offers the 
2098         <guimenuitem>Connect</guimenuitem> entry further above, you
2099         need to click on that one first to achieve the driver
2100         installation as shown in the last section).
2101         </para></step>
2103         <step><para>
2104         Go to the <guilabel>Advanced</guilabel> tab; click on <guibutton>Printing Defaults</guibutton>.
2105         </para></step>
2107         <step><para>
2108         Change the <guimenuitem>Portrait</guimenuitem> page setting to <guimenuitem>Landscape</guimenuitem> (and back).
2109         </para></step>
2111         <step><para>
2112         Make sure to apply changes between swapping the page orientation to cause the change to actually take effect.
2113         </para></step>
2115         <step><para>
2116         While you are at it, you may also want to set the desired printing defaults here, which then apply to all future
2117         client driver installations on the remaining from now on.
2118         </para></step>
2119 </procedure>
2121 <para>
2122 This procedure has executed the printer driver program on the client platform and fed back the correct
2123 Device Mode to Samba, which now stored it in its TDB files. Once the driver is installed on the client,
2124 you can follow the analogous steps by accessing the <emphasis>local</emphasis> <guiicon>Printers</guiicon>
2125 folder, too, if you are a Samba printer admin user. From now on, printing should work as expected.
2126 </para>
2128 <para>
2129 Samba includes a service level parameter name <parameter>default devmode</parameter> for generating a default
2130 Device Mode for a printer. Some drivers will function well with Samba's default set of properties. Others
2131 may crash the client's spooler service. So use this parameter with caution. It is always better to have
2132 the client generate a valid device mode for the printer and store it on the server for you.
2133 </para>
2134 </sect2>
2136 <sect2>
2137 <title>Additional Client Driver Installation</title>
2139 <para>
2140 Every additional driver may be installed, along the lines described
2141 above. Browse network, open the
2142 <guiicon>Printers</guiicon> folder on Samba server, right-click on <guiicon>Printer</guiicon> and choose
2143 <guimenuitem>Connect...</guimenuitem>. Once this completes (should be not more than a few seconds,
2144 but could also take a minute, depending on network conditions), you should find the new printer in your
2145 client workstation local <guiicon>Printers and Faxes</guiicon> folder.
2146 </para>
2148 <para>
2149 You can also open your local <guiicon>Printers and Faxes</guiicon> folder by
2150 using this command on Windows 200x/XP Professional workstations:
2151 </para>
2153 <para><userinput>rundll32 shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder</userinput></para>
2155 <para>
2156 or this command on Windows NT 4.0 workstations:
2157 </para>
2159 <para><userinput>
2160 rundll32 shell32.dll,Control_RunDLL MAIN.CPL @2
2161 </userinput></para>
2163 <para>
2164 You can enter the commands either inside a <guilabel>DOS box</guilabel> window or in the <guimenuitem>Run
2165 command...</guimenuitem> field from the <guimenu>Start</guimenu> menu.
2166 </para>
2167 </sect2>
2169 <sect2>
2170 <title>Always Make First Client Connection as root or <quote>printer admin</quote></title>
2172 <para>
2173 After you installed the driver on the Samba server (in its <smbconfsection name="[print$]"/>
2174 share, you should always make sure that your first client installation completes correctly. Make it a
2175 habit for yourself to build the very first connection from a client as <smbconfoption name="printer admin"/>. This is to make sure that:
2176 </para>
2178 <itemizedlist>
2179         <listitem><para>
2180         A first valid <emphasis>Device Mode</emphasis> is really initialized (see above for more
2181         explanation details).
2182         </para></listitem>
2184         <listitem><para>        
2185         The default print settings of your printer for all further client installations are as you want them.
2186         </para></listitem>
2187 </itemizedlist>
2189 <para>
2190 Do this by changing the orientation to landscape, click on <guiicon>Apply</guiicon>, and then change it
2191 back again. Next, modify the other settings (for example, you do not want the default media size set to
2192 <guiicon>Letter</guiicon> when you are all using <guiicon>A4</guiicon>, right? You may want to set the
2193 printer for <guiicon>duplex</guiicon> as the default, and so on).
2194 </para>
2196 <para>
2197 To connect as root to a Samba printer, try this command from a Windows 200x/XP DOS box command prompt:
2198 </para>
2200 <para><screen>
2201 &dosprompt;<userinput>runas /netonly /user:root "rundll32 printui.dll,PrintUIEntry /p /t3 /n 
2202         \\<replaceable>SAMBA-SERVER</replaceable>\<replaceable>printername</replaceable>"</userinput>
2203 </screen>
2204 </para>
2206 <para>
2207 You will be prompted for root's Samba-password; type it, wait a few
2208 seconds, click on <guibutton>Printing
2209 Defaults</guibutton>, and proceed to set the job options that should be used as defaults by all
2210 clients. Alternately, instead of root you can name one other member of the <smbconfoption name="printer admin"/> from the setting.
2211 </para>
2213 <para>
2214         Now all the other users downloading and installing the driver the same way <?latex \linebreak ?>(called
2215 <quote>Point'n'Print</quote>) will have the same defaults set for them. If you miss this step
2216 you'll get a lot of Help Desk calls from your users, but maybe you like to talk to people.
2217 </para>
2218 </sect2>
2219 </sect1>
2221 <sect1>
2222 <title>Other Gotchas</title>
2224 <para>
2225 Your driver is installed. It is now ready for Point'n'Print
2226 installation by the clients. You may have tried to download and use it
2227 onto your first client machine, but
2228 wait. Let's make sure you are acquainted first with a few tips and tricks you may find useful. For example,
2229 suppose you did not set the defaults on the printer, as advised in the preceding
2230 paragraphs. Your users complain about various issues (such as, <quote>We need to set the paper size
2231 for each job from Letter to A4 and it will not store it.</quote>)
2232 </para>
2234 <sect2>
2235 <title>Setting Default Print Options for Client Drivers</title>
2237 <para>
2238 The last sentence might be viewed with mixed feelings by some users and
2239 Admins. They have struggled for hours and could not arrive at a point
2240 where their settings seemed to be saved. It is not their fault. The confusing
2241 thing is that in the multi-tabbed dialog that pops up when you right-click
2242 on the printer name and select <guimenuitem>Properties</guimenuitem>, you
2243 can arrive at two dialogs that appear identical, each claiming that they help
2244 you to set printer options in three different ways. Here is the definite
2245 answer to the Samba default driver setting FAQ:
2246 </para>
2248 <formalpara><title><quote>I can not set and save default print options
2249 for all users on Windows 200x/XP. Why not?</quote></title>
2251 <para>
2252 How are you doing it? I bet the wrong way. (It is not easy to find out, though). There are three different
2253 ways to bring you to a dialog that seems to set everything. All three
2254 dialogs look the same, but only one
2255 of them does what you intend. You need to be Administrator or Print Administrator to do this for all
2256 users. Here is how I reproduce it in an XP Professional:
2257 </para>
2259 <orderedlist numeration="upperalpha">
2260         <listitem><para>The first <quote>wrong</quote> way:
2261         <orderedlist numeration="arabic">
2262                 <listitem><para>Open the <guiicon>Printers</guiicon> folder.</para></listitem>
2264                 <listitem><para>Right-click on the printer (<emphasis>remoteprinter on cupshost</emphasis>) and
2265                 select in context menu <guimenu>Printing Preferences...</guimenu>.</para></listitem>
2267                 <listitem><para>Look at this dialog closely and remember what it looks like.</para></listitem>
2268         </orderedlist></para></listitem>
2270         <listitem><para>The second <quote>wrong</quote> way:
2271                 <orderedlist numeration="arabic">
2272                         <listitem><para>Open the <guimenu>Printers</guimenu> folder.</para></listitem>
2274                         <listitem><para>Right-click on the printer (<emphasis>remoteprinter on
2275                         cupshost</emphasis>) and select in the context menu
2276                         <guimenuitem>Properties</guimenuitem></para></listitem>
2278                         <listitem><para>Click on the <guilabel>General</guilabel>
2279                         tab.</para></listitem>
2281                         <listitem><para>Click on the <guibutton>Printing
2282                         Preferences...</guibutton> button.</para></listitem>
2284                         <listitem><para>A new dialog opens. Keep this dialog open and go back
2285                         to the parent dialog.</para></listitem>
2286                 </orderedlist>
2287         </para></listitem>
2289         <listitem><para>
2290         The third and correct way: (should you do this from the beginning, just carry out steps 1
2291         and 2 from the second method above).
2292         </para>
2294                 <orderedlist numeration="arabic">
2295                         <listitem><para>Click on the <guilabel>Advanced</guilabel>
2296                         tab. (If everything is <quote>grayed out,</quote> then you are not logged
2297                         in as a user with enough privileges).</para></listitem>
2299                         <listitem><para>Click on the <guibutton>Printing
2300                         Defaults</guibutton> button.</para></listitem>
2302                         <listitem><para>On any of the two new tabs,
2303                         click on the
2304                         <guilabel>Advanced</guilabel> button.</para></listitem>
2306                         <listitem><para>A new dialog opens. Compare
2307                         this one to the other. Are they
2308                         identical looking comparing one from
2309                         <quote>B.5</quote> and one from A.3".</para></listitem>
2310                 </orderedlist>
2311         </listitem>
2312 </orderedlist>
2314 <para>
2315 Do you see any difference in the two settings dialogs? I do not either. However, only the last one, which
2316 you arrived at with steps C.1 through 6 will permanently save any settings which will then become the defaults
2317 for new users. If you want all clients to have the same defaults, you need to conduct these steps as
2318 administrator (<smbconfoption name="printer admin"/> in ) before
2319 a client downloads the driver (the clients can later set their own per-user defaults
2320 by following procedures A or B above). Windows 200x/XP allow per-user default settings and the ones the
2321 administrator gives them, before they set up their own. The parents of the identically-looking dialogs have a slight difference in their window names; one is called <computeroutput>Default Print
2322 Values for Printer Foo on Server Bar"</computeroutput> (which is the one you need) and the other is called
2323 <quote><computeroutput>Print Settings for Printer Foo on Server Bar</computeroutput></quote>. The last one is the one you
2324 arrive at when you right-click on the printer and select <guimenuitem>Print Settings...</guimenuitem>. This
2325 is the one that you were taught to use back in the days of Windows NT, so it is only natural to try the
2326 same way with Windows 200x/XP. You would not dream that there is now a different path to arrive at an
2327 identically looking, but functionally different, dialog to set defaults for all users.
2328 </para></formalpara>
2330 <tip><para>Try (on Windows 200x/XP) to run this command (as a user with the right privileges):
2331 </para>
2333 <para><userinput>
2334 rundll32 printui.dll,PrintUIEntry /p /t3 /n\\<replaceable>SAMBA-SERVER</replaceable>\<replaceable>printersharename</replaceable>
2335 </userinput></para>
2337 <para>
2338 To see the tab with the <guilabel>Printing Defaults</guilabel> button (the one you need),also run this command:
2339 </para>
2341 <para><userinput>
2342 rundll32 printui.dll,PrintUIEntry /p /t0 /n\\<replaceable>SAMBA-SERVER</replaceable>\<replaceable>printersharename</replaceable>
2343 </userinput></para>
2345 <para>
2346 To see the tab with the <guilabel>Printing Preferences</guilabel>
2347 button (the one which does not set system-wide defaults), you can
2348 start the commands from inside a DOS box" or from <guimenu>Start</guimenu> -> <guimenuitem>Run</guimenuitem>.
2349 </para>
2350 </tip>
2352 </sect2>
2354 <sect2>
2355 <title>Supporting Large Numbers of Printers</title>
2357 <para>
2358 One issue that has arisen during the recent development phase of Samba is the need to support driver
2359 downloads for hundreds of printers. Using Windows NT APW here is somewhat awkward (to say the least). If
2360 you do not want to acquire RSS pains from the printer installation clicking orgy alone, you need
2361 to think about a non-interactive script.
2362 </para>
2364 <para>
2365 If more than one printer is using the same driver, the <command>rpcclient setdriver</command>
2366 command can be used to set the driver associated with an installed queue. If the driver is uploaded to
2367 <smbconfsection name="[print$]"/> once and registered with the printing TDBs, it can be used by
2368 multiple print queues. In this case, you just need to repeat the <command>setprinter</command> subcommand of
2369 <command>rpcclient</command> for every queue (without the need to conduct the <command>adddriver</command>
2370 repeatedly). The following is an example of how this could be accomplished:
2371 </para>
2373 <para><screen>
2374 &rootprompt;<userinput>rpcclient <replaceable>SAMBA-CUPS</replaceable> -U root%<replaceable>secret</replaceable> -c 'enumdrivers'</userinput>
2375  cmd = enumdrivers
2377  [Windows NT x86]
2378  Printer Driver Info 1:
2379    Driver Name: [infotec  IS 2075 PCL 6]
2381  Printer Driver Info 1:
2382    Driver Name: [DANKA InfoStream]
2384  Printer Driver Info 1:
2385    Driver Name: [Heidelberg Digimaster 9110 (PS)]
2387  Printer Driver Info 1:
2388    Driver Name: [dm9110]
2390  Printer Driver Info 1:
2391    Driver Name: [mydrivername]
2393  [....]
2394 </screen>
2396 <screen>
2397 &rootprompt;<userinput>rpcclient <replaceable>SAMBA-CUPS</replaceable> -U root%<replaceable>secret</replaceable> -c 'enumprinters'</userinput>
2398  cmd = enumprinters
2399    flags:[0x800000]
2400    name:[\\SAMBA-CUPS\dm9110]
2401    description:[\\SAMBA-CUPS\dm9110,,110ppm HiVolume DANKA Stuttgart]
2402    comment:[110 ppm HiVolume DANKA Stuttgart]
2403  [....]
2404 </screen>
2406 <screen>
2407 &rootprompt;<userinput>rpcclient <replaceable>SAMBA-CUPS</replaceable> -U root%<replaceable>secret</replaceable> -c \
2408   'setdriver <replaceable>dm9110</replaceable> "<replaceable>Heidelberg Digimaster 9110 (PS)</replaceable>"'</userinput>
2409  cmd = setdriver dm9110 Heidelberg Digimaster 9110 (PPD)
2410  Successfully set dm9110 to driver Heidelberg Digimaster 9110 (PS).
2411 </screen>
2413 <screen>
2414 &rootprompt;<userinput>rpcclient <replaceable>SAMBA-CUPS</replaceable> -U root%<replaceable>secret</replaceable> -c 'enumprinters'</userinput>
2415  cmd = enumprinters
2416    flags:[0x800000]
2417    name:[\\SAMBA-CUPS\dm9110]
2418    description:[\\SAMBA-CUPS\dm9110,Heidelberg Digimaster 9110 (PS),\
2419      110ppm HiVolume DANKA Stuttgart]
2420    comment:[110ppm HiVolume DANKA Stuttgart]
2421  [....]
2422 </screen>
2424 <screen>
2425 &rootprompt;<userinput>rpcclient <replaceable>SAMBA-CUPS</replaceable> -U root%<replaceable>secret</replaceable> -c 'setdriver <replaceable>dm9110</replaceable> <replaceable>mydrivername</replaceable>'</userinput>
2426  cmd = setdriver dm9110 mydrivername
2427  Successfully set dm9110 to mydrivername.
2428 </screen>
2430 <screen>
2431 &rootprompt;<userinput>rpcclient <replaceable>SAMBA-CUPS</replaceable> -U root%<replaceable>secret</replaceable> -c 'enumprinters'</userinput>
2432  cmd = enumprinters
2433    flags:[0x800000]
2434    name:[\\SAMBA-CUPS\dm9110]
2435    description:[\\SAMBA-CUPS\dm9110,mydrivername,\
2436      110ppm HiVolume DANKA Stuttgart]
2437    comment:[110ppm HiVolume DANKA Stuttgart]
2438  [....]
2439 </screen></para>
2441 <para>
2442 It may not be easy to recognize that the first call to <command>enumprinters</command> showed the
2443 <quote>dm9110</quote> printer with an empty string where the driver should have been listed (between
2444 the 2 commas in the description field). After the <command>setdriver</command> command
2445 succeeded, all is well.
2446 </para>
2447 </sect2>
2449 <sect2>
2450 <title>Adding New Printers with the Windows NT APW</title>
2452 <para>
2453 By default, Samba exhibits all printer shares defined in &smb.conf; in the <guiicon>Printers</guiicon>
2454 folder. Also located in this folder is the Windows NT Add Printer Wizard icon. The APW will be shown only if:
2455 </para>
2457 <itemizedlist>
2458         <listitem><para>
2459         The connected user is able to successfully execute an <command>OpenPrinterEx(\\server)</command> with
2460         administrative privileges (i.e., root or <smbconfoption name="printer admin"/>).
2461         </para>
2463         <tip><para> Try this from a Windows 200x/XP DOS box command prompt:
2464         </para>
2466         <para><userinput>
2467         runas /netonly /user:root rundll32 printui.dll,PrintUIEntry /p /t0 /n \\<replaceable>SAMBA-SERVER</replaceable>\<replaceable>printersharename</replaceable>
2468         </userinput></para>
2470         <para>
2471         Click on <guibutton>Printing Preferences</guibutton>.
2472         </para></tip></listitem>
2474         <listitem><para>... contains the setting
2475         <smbconfoption name="show add printer wizard">yes</smbconfoption> (the
2476         default).</para></listitem>
2477 </itemizedlist>
2479 <para>
2480 The APW can do various things:
2481 </para>
2483 <itemizedlist>
2484         <listitem><para>
2485         Upload a new driver to the Samba <smbconfsection name="[print$]"/> share.
2486         </para></listitem>
2488         <listitem><para>
2489         Associate an uploaded driver with an existing (but still driverless) print queue.
2490         </para></listitem>
2492         <listitem><para>
2493         Exchange the currently used driver for an existing print queue with one that has been uploaded before.
2494         </para></listitem>
2496         <listitem><para>
2497         Add an entirely new printer to the Samba host (only in conjunction with a working
2498         <smbconfoption name="add printer command"/>. A corresponding
2499         <smbconfoption name="delete printer command"/> for removing entries from the
2500         <guiicon>Printers</guiicon> folder may also be provided).
2501         </para></listitem>
2502 </itemizedlist>
2504 <para>
2505 The last one (add a new printer) requires more effort than the previous ones. To use
2506 the APW to successfully add a printer to a Samba server, the <smbconfoption name="add printer command"/> must have a defined value. The program hook must successfully
2507 add the printer to the UNIX print system (i.e., to <filename>/etc/printcap</filename>,
2508 <filename>/etc/cups/printers.conf</filename> or other appropriate files) and to &smb.conf; if necessary.
2509 </para>
2511 <para>
2512 When using the APW from a client, if the named printer share does not exist, smbd will execute the
2513 <smbconfoption name="add printer command"/> and re-parse to the to attempt to locate the new printer
2514 share. If the share is still not defined, an error of <errorname>Access Denied</errorname> is returned to
2515 the client. The <smbconfoption name="add printer command"/> is executed
2516 under the context of the connected user, not necessarily a root account. A <smbconfoption name="map to guest">bad user</smbconfoption> may have connected you unwittingly under the wrong
2517 privilege. You should check it by using the <command>smbstatus</command> command.
2518 </para>
2520 </sect2>
2522 <sect2>
2523 <title>Error Message: <quote><errorname>Cannot connect under a different Name</errorname></quote></title>
2525 <para>
2526 Once you are connected with the wrong credentials, there is no means to reverse the situation other than
2527 to close all Explorer Windows, and perhaps reboot.
2528 </para>
2530 <itemizedlist>
2531         <listitem><para>
2532         The <command>net use \\SAMBA-SERVER\sharename /user:root</command> gives you an error message:
2533         <quote>Multiple connections to a server or a shared resource by the same user utilizing
2534         the several user names are not allowed. Disconnect all previous connections to the server,
2535         esp. the shared resource, and try again.</quote>
2536         </para></listitem>
2538         <listitem><para>
2539         Every attempt to <quote>connect a network drive</quote> to <filename>\\SAMBASERVER\\print$</filename>
2540         to <constant>z:</constant> is countered by the pertinacious message: <quote>This
2541         network folder is currently connected under different credentials (username and password).
2542         Disconnect first any existing connection to this network share in order to connect again under
2543         a different username and password</quote>.
2544         </para></listitem>
2545 </itemizedlist>
2547 <para>
2548 So you close all connections. You try again. You get the same message. You check from the Samba side,
2549 using <command>smbstatus</command>. Yes, there are more connections. You kill them all. The client
2550 still gives you the same error message. You watch the smbd.log file on a high debug level and try
2551 reconnect. Same error message, but not a single line in the log. You start to wonder if there was a
2552 connection attempt at all. You run ethereal and tcpdump while you try to connect. Result: not a single
2553 byte goes on the wire. Windows still gives the error message. You close all Explorer windows and start it
2554 again. You try to connect &smbmdash; and this times it works!  Windows seems to cache connection information somewhere and
2555 does not keep it up-to-date (if you are unlucky you might need to reboot to get rid of the error message).
2556 </para>
2558 <para>
2559 The easiest way to forcefully terminate all connections from your client to a server is by executing:
2560 <screen>
2561 &dosprompt; net use * /delete
2562 </screen>
2563 This will disconnect all mapped drives also and will allow you create fresh connection as required.
2564 </para>
2565 </sect2>
2567 <sect2>
2568 <title>Take Care When Assembling Driver Files</title>
2570 <para>
2571 You need to be extremely careful when you take notes about the files and belonging to a particular
2572 driver. Don't confuse the files for driver version <quote>0</quote> (for Windows 9x/Me, going into
2573 <filename>[print$]/WIN/0/</filename>), driver version <filename>2</filename> (Kernel Mode driver for Windows NT,
2574 going into <filename>[print$]/W32X86/2/</filename> may be used on Windows 200x/XP also), and
2575 driver version <quote>3</quote> (non-Kernel Mode driver going into <filename>[print$]/W32X86/3/</filename>
2576 cannot be used on Windows NT). Quite often these different driver versions contain
2577 files that have the same name but actually are very different. If you look at them from
2578 the Windows Explorer (they reside in <filename>%WINDOWS%\system32\spool\drivers\W32X86\</filename>),
2579 you will probably see names in capital letters, while an <command>enumdrivers</command> command from Samba
2580 would show mixed or lower case letters. So it is easy to confuse them. If you install them manually using
2581 <command>rpcclient</command> and subcommands, you may even succeed without an error message. Only later,
2582 when you try install on a client, you will encounter error messages like <computeroutput>This server
2583 has no appropriate driver for the printer</computeroutput>.
2584 </para>
2586 <para>
2587 Here is an example. You are invited to look closely at the various files, compare their names and
2588 their spelling, and discover the differences in the composition of the version 2 and 3 sets. Note: the
2589 version 0 set contained 40 <parameter>Dependentfiles</parameter>, so I left it out for space reasons:
2590 </para>
2592 <para><screen>
2593 &rootprompt;<userinput>rpcclient -U 'Administrator%<replaceable>secret</replaceable>' -c 'enumdrivers 3' 10.160.50.8 </userinput>
2595  Printer Driver Info 3:
2596          Version: [3]
2597          Driver Name: [Canon iR8500 PS3]
2598          Architecture: [Windows NT x86]
2599          Driver Path: [\\10.160.50.8\print$\W32X86\3\cns3g.dll]
2600          Datafile: [\\10.160.50.8\print$\W32X86\3\iR8500sg.xpd]
2601          Configfile: [\\10.160.50.8\print$\W32X86\3\cns3gui.dll]
2602          Helpfile: [\\10.160.50.8\print$\W32X86\3\cns3g.hlp]
2604          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\aucplmNT.dll]
2605          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\ucs32p.dll]
2606          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\tnl32.dll]
2607          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\aussdrv.dll]
2608          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\cnspdc.dll]
2609          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\aussapi.dat]
2610          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\cns3407.dll]
2611          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\CnS3G.cnt]
2612          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\NBAPI.DLL]
2613          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\NBIPC.DLL]
2614          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\cpcview.exe]
2615          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\cpcdspl.exe]
2616          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\cpcedit.dll]
2617          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\cpcqm.exe]
2618          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\cpcspl.dll]
2619          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\cfine32.dll]
2620          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\cpcr407.dll]
2621          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\Cpcqm407.hlp]
2622          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\cpcqm407.cnt]
2623          Dependentfiles: [\\10.160.50.8\print$\W32X86\3\cns3ggr.dll]
2625          Monitorname: []
2626          Defaultdatatype: []
2628  Printer Driver Info 3:
2629          Version: [2]
2630          Driver Name: [Canon iR5000-6000 PS3]
2631          Architecture: [Windows NT x86]
2632          Driver Path: [\\10.160.50.8\print$\W32X86\2\cns3g.dll]
2633          Datafile: [\\10.160.50.8\print$\W32X86\2\IR5000sg.xpd]
2634          Configfile: [\\10.160.50.8\print$\W32X86\2\cns3gui.dll]
2635          Helpfile: [\\10.160.50.8\print$\W32X86\2\cns3g.hlp]
2637          Dependentfiles: [\\10.160.50.8\print$\W32X86\2\AUCPLMNT.DLL]
2638          Dependentfiles: [\\10.160.50.8\print$\W32X86\2\aussdrv.dll]
2639          Dependentfiles: [\\10.160.50.8\print$\W32X86\2\cnspdc.dll]
2640          Dependentfiles: [\\10.160.50.8\print$\W32X86\2\aussapi.dat]
2641          Dependentfiles: [\\10.160.50.8\print$\W32X86\2\cns3407.dll]
2642          Dependentfiles: [\\10.160.50.8\print$\W32X86\2\CnS3G.cnt]
2643          Dependentfiles: [\\10.160.50.8\print$\W32X86\2\NBAPI.DLL]
2644          Dependentfiles: [\\10.160.50.8\print$\W32X86\2\NBIPC.DLL]
2645          Dependentfiles: [\\10.160.50.8\print$\W32X86\2\cns3gum.dll]
2647          Monitorname: [CPCA Language Monitor2]
2648          Defaultdatatype: []
2650 </screen></para>
2652 <para>
2653 If we write the <quote>version 2</quote> files and the <quote>version 3</quote> files
2654 into different text files and compare the result, we see this
2655 picture:
2656 </para>
2658 <para><screen>
2659 &rootprompt;<userinput>sdiff 2-files 3-files</userinput>
2661 <![CDATA[
2662  cns3g.dll                     cns3g.dll
2663  iR8500sg.xpd                  iR8500sg.xpd
2664  cns3gui.dll                   cns3gui.dll
2665  cns3g.hlp                     cns3g.hlp
2666  AUCPLMNT.DLL                | aucplmNT.dll
2667                              > ucs32p.dll
2668                              > tnl32.dll
2669  aussdrv.dll                   aussdrv.dll
2670  cnspdc.dll                    cnspdc.dll
2671  aussapi.dat                   aussapi.dat
2672  cns3407.dll                   cns3407.dll
2673  CnS3G.cnt                     CnS3G.cnt
2674  NBAPI.DLL                     NBAPI.DLL
2675  NBIPC.DLL                     NBIPC.DLL
2676  cns3gum.dll                 | cpcview.exe
2677                              > cpcdspl.exe 
2678                              > cpcqm.exe
2679                              > cpcspl.dll
2680                              > cfine32.dll
2681                              > cpcr407.dll
2682                              > Cpcqm407.hlp
2683                              > cpcqm407.cnt
2684                              > cns3ggr.dll
2686 </screen>
2688 Do not be fooled! Driver files for each version with identical
2689 names may be different in their content, as you can see from this size
2690 comparison:
2691 </para>
2693 <para><screen>
2694 &rootprompt;<userinput>for i in cns3g.hlp cns3gui.dll cns3g.dll; do                  \
2695            smbclient //10.160.50.8/print\$ -U 'Administrator%xxxx' \
2696            -c "cd W32X86/3; dir $i; cd .. ; cd 2; dir $i";      \
2697                    done</userinput>
2699   CNS3G.HLP               A   122981  Thu May 30 02:31:00 2002
2700   CNS3G.HLP               A    99948  Thu May 30 02:31:00 2002
2702   CNS3GUI.DLL             A  1805824  Thu May 30 02:31:00 2002
2703   CNS3GUI.DLL             A  1785344  Thu May 30 02:31:00 2002
2705   CNS3G.DLL               A  1145088  Thu May 30 02:31:00 2002
2706   CNS3G.DLL               A    15872  Thu May 30 02:31:00 2002
2707 </screen></para>
2709 <para>
2710 In my example were even more differences than shown here. Conclusion: you must be careful to select
2711 the correct driver files for each driver version. Don't rely on the
2712 names alone and don't interchange files
2713 belonging to different driver versions.
2714 </para>
2715 </sect2>
2717 <sect2>
2718 <title>Samba and Printer Ports</title>
2720 <para>
2721 Windows NT/2000 print servers associate a port with each printer. These normally take the form of
2722 <filename>LPT1:</filename>, <filename>COM1:</filename>,
2723 <filename>FILE:</filename>, and so on. Samba must also
2724 support the concept of ports associated with a printer. By default, only one printer port, named <quote>Samba
2725 Printer Port</quote>, exists on a system. Samba does not really need such a <quote>port</quote> in order
2726 to print; rather it is a requirement of Windows clients. They insist on being told about an available
2727 port when they request this information, otherwise they throw an error message at you. So Samba fakes the port
2728 information to keep the Windows clients happy.
2729 </para>
2731 <para>
2732 Samba does not support the concept of <constant>Printer Pooling</constant> internally either. Printer
2733 Pooling assigns a logical printer to multiple ports as a form of load balancing or fail over.
2734 </para>
2736 <para>
2737 If you require multiple ports be defined for some reason or another (my users and my boss should not know
2738 that they are working with Samba), configure <smbconfoption name="enumports command"/>
2739 which can be used to define an external program that generates a listing of ports on a system.
2740 </para>
2741 </sect2>
2743 <sect2>
2744 <title>Avoiding Common Client Driver Mis-configuration</title>
2746 <para>
2747 So now the printing works, but there are still problems. Most jobs print well, some do not print at
2748 all. Some jobs have problems with fonts, which do not look good. Some jobs print fast and some
2749 are dead-slow. We cannot cover it all, but we want to encourage you to read the brief paragraph about
2750 <quote>Avoiding the Wrong PostScript Driver Settings</quote> in the CUPS Printing part of this document.
2751 </para>
2752 </sect2>
2753 </sect1>
2755 <sect1>
2756 <title>The Imprints Tool-set</title>
2758 <para>
2759 The Imprints tool set provides a UNIX equivalent of the Windows NT Add Printer
2760 Wizard. For complete information, please refer to the 
2761 <ulink url="http://imprints.sourceforge.net/">Imprints</ulink> Web site as well as the documentation
2762 included with the imprints source distribution. This section only provides a brief introduction to
2763 the features of Imprints.
2764 </para>
2766 <para>
2767 Unfortunately, the Imprints tool-set is no longer maintained. As of December 2000, the project is in
2768 need of a new maintainer. The most important skill to have is Perl coding and an interest in MS-RPC-based
2769 printing used in Samba. If you wish to volunteer, please coordinate
2770 your efforts on the Samba technical
2771 mailing list. The tool-set is still in usable form, but only for a series of older printer models where
2772 there are prepared packages to use. Packages for more up-to-date print devices are needed if Imprints
2773 should have a future.
2774 </para>
2776 <sect2>
2777 <title>What is Imprints?</title>
2779 <para>
2780 Imprints is a collection of tools for supporting these goals:
2781 </para>
2783 <itemizedlist>
2784         <listitem><para>
2785         Providing a central repository of information regarding Windows NT and 95/98 printer driver packages.
2786         </para></listitem>
2788         <listitem><para>
2789         Providing the tools necessary for creating the Imprints printer driver packages.
2790         </para></listitem>
2792         <listitem><para>
2793         Providing an installation client that will obtain printer drivers from a central Internet (or intranet) Imprints Server
2794         repository and install them on remote Samba and Windows NT4 print servers.
2795         </para></listitem>
2796 </itemizedlist>
2797 </sect2>
2799 <sect2>
2800 <title>Creating Printer Driver Packages</title>
2802 <para>
2803 The process of creating printer driver packages is beyond the scope of this document (refer to Imprints.txt
2804 also included with the Samba distribution for more information). In short, an Imprints driver package
2805 is a gzipped tarball containing the driver files, related INF files, and a control file needed by the
2806 installation client.
2807 </para>
2808 </sect2>
2810 <sect2>
2811 <title>The Imprints Server</title>
2813 <para>
2814 The Imprints server is really a database server that may be queried via standard HTTP mechanisms. Each
2815 printer entry in the database has an associated URL for the actual downloading of the package. Each
2816 package is digitally signed via GnuPG which can be used to verify that
2817 the package downloaded is actually
2818 the one referred in the Imprints database. It is strongly recommended that this security check
2819 not be disabled.
2820 </para>
2821 </sect2>
2823 <sect2>
2824 <title>The Installation Client</title>
2826 <para>
2827 More information regarding the Imprints installation client is available from the the documentation file
2828 <filename>Imprints-Client-HOWTO.ps</filename> that is included with the Imprints source package. The Imprints
2829 installation client comes in two forms:
2830 </para>
2832 <itemizedlist>
2833         <listitem><para>A set of command line Perl scripts.</para></listitem>
2834         <listitem><para>A GTK+ based graphical interface to the command line Perl scripts.</para></listitem>
2835 </itemizedlist>
2837 <para>
2838 The installation client (in both forms) provides a means of querying the Imprints database server for
2839 a matching list of known printer model names as well as a means to download and install the drivers on
2840 remote Samba and Windows NT print servers.
2841 </para>
2843 <para>
2844 The basic installation process is in four steps and Perl code is wrapped around smbclient and rpcclient.
2845 </para>
2847 <itemizedlist>
2848         <listitem><para>
2849         For each supported architecture for a given driver:
2850         <orderedlist>
2851                 <listitem><para>rpcclient: Get the appropriate upload directory on the remote server.</para></listitem>
2852                 <listitem><para>smbclient: Upload the driver files.</para></listitem>
2853                 <listitem><para>rpcclient: Issues an AddPrinterDriver() MS-RPC.</para></listitem>
2854         </orderedlist>
2855         </para></listitem>
2857         <listitem><para>rpcclient: Issue an AddPrinterEx() MS-RPC to actually create the printer.</para></listitem>
2858 </itemizedlist>
2860 <para>
2861 One of the problems encountered when implementing the Imprints tool set was the name space issues between
2862 various supported client architectures. For example, Windows NT includes a driver named <quote>Apple LaserWriter
2863 II NTX v51.8</quote> and Windows 95 calls its version of this driver <quote>Apple LaserWriter II NTX</quote>.
2864 </para>
2866 <para>
2867 The problem is how to know what client drivers have been uploaded for a printer. An astute reader will
2868 remember that the Windows NT Printer Properties dialog only includes space for one printer driver name. A
2869 quick look in the Windows NT 4.0 system registry at:
2870 </para>
2872 <para><filename>
2873  HKLM\System\CurrentControlSet\Control\Print\Environment
2874 </filename></para>
2876 <para>
2877 will reveal that Windows NT always uses the NT driver name. This is okay as Windows NT always requires
2878 that at least the Windows NT version of the printer driver is present. Samba does not have the
2879 requirement internally, therefore, <quote>How can you use the NT driver name if it has not already been installed?</quote>
2880 </para>
2882 <para>
2883 The way of sidestepping this limitation is to require that all Imprints printer driver packages include both the Intel Windows NT and
2884 95/98 printer drivers and that the NT driver is installed first.
2885 </para>
2886 </sect2>
2887 </sect1>
2889 <sect1>
2890 <title>Adding Network Printers without User Interaction</title>
2892 <para>
2893 The following MS Knowledge Base article may be of some help if you need to handle Windows 2000
2894 clients: <emphasis>How to Add Printers with No User Interaction in Windows 2000,</emphasis> (<ulink
2895 url="http://support.microsoft.com/default.aspx?scid=kb;en-us;189105">http://support.microsoft.com/default.aspx?scid=kb;en-us;189105</ulink>).
2896 It also applies to Windows XP Professional clients.
2897 The ideas sketched out in this section are inspired by this article, which describes a command-line method that can be
2898 applied to install network and local printers and their drivers. This is most useful if integrated in Logon
2899 Scripts. You can see what options are available by typing in the command prompt (<command>DOS box</command>):
2900 </para>
2902 <para><userinput>rundll32 printui.dll,PrintUIEntry /?</userinput></para>
2904 <para>
2905 A window pops up that shows you all of the command-line switches available. An extensive list of examples
2906 is also provided. This is only for Win 200x/XP, it does not work on
2907 Windows NT. Windows NT probably has
2908 some other tools in the respective Resource Kit. Here is a suggestion about what a client logon script
2909 might contain, with a short explanation of what the lines actually do (it works if 200x/XP Windows
2910 clients access printers via Samba, and works for Windows-based print servers too):
2911 </para>
2913 <para><screen>
2914 <userinput>rundll32 printui.dll,PrintUIEntry /dn /n "\\cupsserver\infotec2105-IPDS" /q</userinput>
2915 <userinput>rundll32 printui.dll,PrintUIEntry /in /n "\\cupsserver\infotec2105-PS"</userinput>
2916 <userinput>rundll32 printui.dll,PrintUIEntry /y /n "\\cupsserver\infotec2105-PS"</userinput>
2917 </screen></para>
2919 <para>
2920 Here is a list of the used command-line parameters: 
2921 </para>
2923 <variablelist>
2924         <varlistentry><term>/dn</term>
2925                 <listitem><para>deletes a network printer</para></listitem>
2926         </varlistentry>
2927         <varlistentry><term>/q</term>
2928                 <listitem><para>quiet modus</para></listitem>
2929         </varlistentry>
2930         <varlistentry><term>/n</term>
2931                 <listitem><para>names a printer</para></listitem>
2932         </varlistentry>
2933         <varlistentry><term>/in</term>
2934                 <listitem><para>adds a network printer connection</para></listitem>
2935         </varlistentry>
2936         <varlistentry><term>/y</term>
2937                 <listitem><para>sets printer as default printer</para></listitem>
2938         </varlistentry>
2939 </variablelist>
2941 <itemizedlist>
2942         <listitem><para>
2943         Line 1 deletes a possibly existing previous network printer <emphasis>infotec2105-IPDS</emphasis>
2944         (which had used native Windows drivers with LPRng that were removed from the server that was
2945         converted to CUPS). The <command>/q</command> at the end eliminates Confirm
2946         or error dialog boxes from popping up. They should not be presented to the user logging on.
2947         </para></listitem>
2949         <listitem><para>        
2950         Line 2 adds the new printer
2951         <emphasis>infotec2105-PS</emphasis> (which actually is the same
2952         physical device but is now run by the new CUPS printing system and associated with the
2953         CUPS/Adobe PS drivers). The printer and its driver must have been added to Samba prior to
2954         the user logging in (e.g., by a procedure as discussed earlier in this chapter, or by running
2955         <command>cupsaddsmb</command>). The driver is now auto-downloaded to the client PC where the
2956         user is about to log in.
2957         </para></listitem>
2959         <listitem><para>
2960         Line 3 sets the default printer to this new network printer (there might be several other
2961         printers installed with this same method and some may be local as well, so we decide for a
2962         default printer). The default printer selection may, of course, be different for different users.
2963         </para></listitem>
2964 </itemizedlist>
2966 <para>
2967 The second line only works if the printer <emphasis>infotec2105-PS</emphasis> has an already working
2968 print queue on the <constant>cupsserver</constant>, and if the
2969 printer drivers have been successfully uploaded
2970 (via the <command>APW</command>, <command>smbclient/rpcclient</command>, or <command>cupsaddsmb</command>)
2971 into the <smbconfsection name="[print$]"/> driver repository of Samba. Some Samba versions
2972 prior to version 3.0 required a re-start of smbd after the printer install and the driver upload,
2973 otherwise the script (or any other client driver download) would fail.
2974 </para>
2976 <para>
2977 Since there no easy way to test for the existence of an installed network printer from the logon script,
2978 do not bother checking, just allow the de-installation/re-installation to occur every time a user logs in;
2979 it's really quick anyway (1 to 2 seconds).
2980 </para>
2982 <para>
2983 The additional benefits for this are:
2984 </para>
2986 <itemizedlist>
2987         <listitem><para>
2988         It puts in place any printer default setup changes automatically at every user logon.
2989         </para></listitem>
2991         <listitem><para>
2992         It allows for <quote>roaming</quote> users' login into the domain from different workstations.
2993         </para></listitem>
2994 </itemizedlist>
2996 <para>
2997 Since network printers are installed per user, this much simplifies the process of keeping the installation
2998 up-to-date. The few extra seconds at logon time will not really be noticeable. Printers can be centrally
2999 added, changed and deleted at will on the server with no user intervention required from the clients
3000 (you just need to keep the logon scripts up-to-date).
3001 </para>
3002 </sect1>
3004 <sect1>
3005 <title>The <command>addprinter</command> Command</title>
3007 <para>
3008 The <command>addprinter</command> command can be configured to be a shell script or program executed by
3009 Samba. It is triggered by running the APW from a client against the Samba print server. The APW asks
3010 the user to fill in several fields (such as printer name, driver to be used, comment, port monitor,
3011 and so on). These parameters are passed on to Samba by the APW. If the addprinter command is designed in a
3012 way that it can create a new printer (through writing correct printcap entries on legacy systems, or
3013 execute the <command>lpadmin</command> command on more modern systems) and create the associated share
3014 in, then the APW will in effect really create a new printer on Samba and the UNIX print subsystem!
3015 </para>
3016 </sect1>
3018 <sect1>
3019 <title>Migration of Classical Printing to Samba</title>
3021 <para>
3022 The basic NT-style printer driver management has not changed considerably in 3.0 over the 2.2.x releases
3023 (apart from many small improvements). Here migration should be quite easy, especially if you followed
3024 previous advice to stop using deprecated parameters in your setup. For migrations from an existing 2.0.x
3025 setup, or if you continued Windows 9x/Me-style printing in your Samba 2.2 installations, it is more of
3026 an effort. Please read the appropriate release notes and the HOWTO Collection for Samba-2.2.x. You can
3027 follow several paths. Here are possible scenarios for migration:
3028 </para>
3030 <itemizedlist>
3031         <listitem><para>
3032         You need to study and apply the new Windows NT printer and driver support. Previously used
3033         parameters <parameter>printer driver file</parameter>, <parameter>printer driver</parameter>
3034         and <parameter>printer driver location</parameter> are no longer supported.
3035         </para></listitem>
3037         <listitem><para>
3038         If you want to take advantage of Windows NT printer driver support, you also need to migrate the
3039         Windows 9x/Me drivers to the new setup.
3040         </para></listitem>
3042         <listitem><para>
3043         An existing <filename>printers.def</filename> file (the one specified in the now removed parameter
3044         <parameter>printer driver file</parameter>) will no longer work with Samba-3. In 3.0, smbd attempts
3045         to locate a Windows 9x/Me driver files for the printer in <smbconfsection name="[print$]"/>
3046         and additional settings in the TDB and only there; if it fails, it will <emphasis>not</emphasis>
3047         (as 2.2.x used to do) drop down to using a <filename>printers.def</filename> (and all associated
3048         parameters). The make_printerdef tool is removed and there is no backward compatibility for this.
3049         </para></listitem>
3051         <listitem><para>You need to install a Windows 9x/Me driver into the
3052         <smbconfsection name="[print$]"/> share for a printer on your Samba
3053         host. The driver files will be stored in the <quote>WIN40/0</quote> subdirectory of
3054         <smbconfsection name="[print$]"/>, and some other settings and information go
3055         into the printing-related TDBs.</para></listitem>
3057         <listitem><para>If you want to migrate an existing
3058         <filename>printers.def</filename> file into the new setup, the
3059         only current
3060         solution is to use the Windows NT APW to install the NT drivers
3061         and the 9x/Me drivers. This can be scripted using smbclient and
3062         rpcclient. See the Imprints installation client at:
3063         </para>
3065         <para>
3066                 <ulink noescape="1" url="http://imprints.sourceforge.net/">http://imprints.sourceforge.net/</ulink>
3067         </para>
3069         <para>
3070         for an example. See also the discussion of rpcclient usage in the
3071         <quote>CUPS Printing</quote> section.</para></listitem>
3072 </itemizedlist>
3073 </sect1>
3075 <sect1>
3076 <title>Publishing Printer Information in Active Directory or LDAP</title>
3078 <para>
3079 This will be addressed in a later update of this document. If you wish to volunteer your services to help
3080 document this, please contact <ulink url="mail://jht@samba.org">John H Terpstra.</ulink>
3081 </para>
3082 </sect1>
3084 <sect1>
3085 <title>Common Errors</title>
3087 <sect2>
3088 <title>I Give My Root Password but I Do Not Get Access</title>
3090 <para>
3091 Do not confuse the root password which is valid for the UNIX system (and in most cases stored in the
3092 form of a one-way hash in a file named <filename>/etc/shadow</filename>), with the password used to
3093 authenticate against Samba. Samba does not know the UNIX password. Root access to Samba resources
3094 requires that a Samba account for root must first be created. This is done with the <command>smbpasswd</command>
3095 command as follows:
3096 </para>
3098 <para><screen>
3099 &rootprompt; smbpasswd -a root
3100 New SMB password: secret
3101 Retype new SMB password: secret
3102 </screen></para>
3104 </sect2>
3106 <sect2>
3107 <title>My Print Jobs Get Spooled into the Spooling Directory, but Then Get Lost</title>
3109 <para>
3110 Do not use the existing UNIX print system spool directory for the Samba spool directory. It may seem
3111 convenient and a savings of space, but it only leads to problems. The two must be separate.
3112 </para>
3114 </sect2>
3115 </sect1>
3117 </chapter>