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