Chapter 21. Classical Printing Support

Kurt Pfeifle

Danka Deutschland GmbH

Gerald (Jerry) Carter

Samba Team

John H. Terpstra

Samba Team

May 31, 2003

Table of Contents

Features and Benefits
Technical Introduction
Client to Samba Print Job Processing
Printing-Related Configuration Parameters
Simple Print Configuration
Verifying Configuration with testparm
Rapid Configuration Validation
Extended Printing Configuration
Detailed Explanation Settings
Printing Developments Since Samba-2.2
Point'n'Print Client Drivers on Samba Servers
The Obsoleted [printer$] Section
Creating the [print$] Share
[print$] Stanza Parameters
The [print$] Share Directory
Installing Drivers into [print$]
Add Printer Wizard Driver Installation
Installing Print Drivers Using rpcclient
Client Driver Installation Procedure
First Client Driver Installation
Setting Device Modes on New Printers
Additional Client Driver Installation
Always Make First Client Connection as root or “printer admin
Other Gotchas
Setting Default Print Options for Client Drivers
Supporting Large Numbers of Printers
Adding New Printers with the Windows NT APW
Error Message: “Cannot connect under a different Name
Take Care When Assembling Driver Files
Samba and Printer Ports
Avoiding Common Client Driver Misconfiguration
The Imprints Toolset
What Is Imprints?
Creating Printer Driver Packages
The Imprints Server
The Installation Client
Adding Network Printers without User Interaction
The addprinter Command
Migration of Classical Printing to Samba
Publishing Printer Information in Active Directory or LDAP
Common Errors
I Give My Root Password but I Do Not Get Access
My Print Jobs Get Spooled into the Spooling Directory, but Then Get Lost

Features and Benefits

Printing is often a mission-critical service for the users. Samba can provide this service reliably and seamlessly for a client network consisting of Windows workstations.

A Samba print service may be run on a standalone or domain member server, side by side with file serving functions, or on a dedicated print server. It can be made as tightly or as loosely secured as needs dictate. Configurations may be simple or complex. Available authentication schemes are essentially the same as described for file services in previous chapters. Overall, Samba's printing support is now able to replace an NT or Windows 2000 print server full-square, with additional benefits in many cases. Clients may download and install drivers and printers through their familiar Point'n'Print mechanism. Printer installations executed by Logon Scripts are no problem. Administrators can upload and manage drivers to be used by clients through the familiar Add Printer Wizard. As an additional benefit, driver and printer management may be run from the command line or through scripts, making it more efficient in case of large numbers of printers. If a central accounting of print jobs (tracking every single page and supplying the raw data for all sorts of statistical reports) is required, this function is best supported by the newer Common UNIX Printing System (CUPS) as the print subsystem underneath the Samba hood.

This chapter outlines the fundamentals of Samba printing as implemented by the more traditional UNIX BSD- and System V-style printing systems. Much of the information in this chapter applies also to CUPS. If you use CUPS, you may be tempted to jump to the next chapter, but you will certainly miss a few things if you do. For further information refer to CUPS Printing Support.

Note

Most of the following examples have been verified on Windows XP Professional clients. Where this document describes the responses to commands given, bear in mind that Windows 200x/XP clients are quite similar but may differ in minor details. Windows NT4 is somewhat different again.

Technical Introduction

Samba's printing support always relies on the installed print subsystem of the UNIX OS it runs on. Samba is a middleman. It takes print files from Windows (or other SMB) clients and passes them to the real printing system for further processing; therefore, it needs to communicate with both sides: the Windows print clients and the UNIX printing system. Hence, we must differentiate between the various client OS types, each of which behave differently, as well as the various UNIX print subsystems, which themselves have different features and are accessed differently.

This chapter deals with the traditional way of UNIX printing. The next chapter covers in great detail the more modern CUPS.

Important

CUPS users, be warned: do not just jump on to the next chapter. You might miss important information only found here!

It is apparent from postings on the Samba mailing list that print configuration is one of the most problematic aspects of Samba administration today. Many new Samba administrators have the impression that Samba performs some sort of print processing. Rest assured, Samba does not perform any type of print processing. It does not do any form of print filtering.

Samba obtains from its clients a data stream (print job) that it spools to a local spool area. When the entire print job has been received, Samba invokes a local UNIX/Linux print command and passes the spooled file to it. It is up to the local system printing subsystems to correctly process the print job and to submit it to the printer.

Client to Samba Print Job Processing

Successful printing from a Windows client via a Samba print server to a UNIX printer involves six (potentially seven) stages:

  1. Windows opens a connection to the printer share.

  2. Samba must authenticate the user.

  3. Windows sends a copy of the print file over the network into Samba's spooling area.

  4. Windows closes the connection.

  5. Samba invokes the print command to hand the file over to the UNIX print subsystem's spooling area.

  6. The UNIX print subsystem processes the print job.

  7. The print file may need to be explicitly deleted from the Samba spooling area. This item depends on your print spooler configuration settings.

Printing-Related Configuration Parameters

There are a number of configuration parameters to control Samba's printing behavior. Please refer to the man page for smb.conf for an overview of these. As with other parameters, there are global-level (tagged with a G in the listings) and service-level (S) parameters.

Global Parameters

These may not go into individual share definitions. If they go in by error, the testparm utility can discover this (if you run it) and tell you so.

Service-Level Parameters

These may be specified in the [global] section of smb.conf. In this case they define the default behavior of all individual or service-level shares (provided they do not have a different setting defined for the same parameter, thus overriding the global default).

Simple Print Configuration

Simple Configuration with BSD Printing shows a simple printing configuration. If you compare this with your own, you may find additional parameters that have been preconfigured by your OS vendor. Following is a discussion and explanation of the parameters. This example does not use many parameters. However, in many environments these are enough to provide a valid smb.conf file that enables all clients to print.

Example 21.1. Simple Configuration with BSD Printing

[global]
printing = bsd
load printers = yes
[printers]
path = /var/spool/samba
printable = yes
public = yes
writable = no

This is only an example configuration. Samba assigns default values to all configuration parameters. The defaults are conservative and sensible. When a parameter is specified in the smb.conf file, this overwrites the default value. The testparm utility when run as root is capable of reporting all settings, both default as well as smb.conf file settings. Testparm gives warnings for all misconfigured settings. The complete output is easily 360 lines and more, so you may want to pipe it through a pager program.

The syntax for the configuration file is easy to grasp. You should know that is not very picky about its syntax. As has been explained elsewhere in this book, Samba tolerates some spelling errors (such as browseable instead of browsable), and spelling is case-insensitive. It is permissible to use Yes/No or True/False for Boolean settings. Lists of names may be separated by commas, spaces, or tabs.

Verifying Configuration with testparm

To see all (or at least most) printing-related settings in Samba, including the implicitly used ones, try the command outlined below. This command greps for all occurrences of lp, print, spool, driver, ports, and [ in testparm's output. This provides a convenient overview of the running smbd print configuration. This command does not show individually created printer shares or the spooling paths they may use. Here is the output of my Samba setup, with settings shown in the example above:

root# testparm -s -v | egrep "(lp|print|spool|driver|ports|\[)"
 Load smb config files from /etc/samba/smb.conf
 Processing section "[homes]"
 Processing section "[printers]"
 
 [global]
        smb ports = 139 445
        lpq cache time = 10
        load printers = Yes
        printcap name = /etc/printcap
        disable spoolss = No
        enumports command =
        addprinter command = 
        deleteprinter command = 
        show add printer wizard = Yes
        os2 driver map =
        printer admin =
        min print space = 0
        max print jobs = 1000
        printable = No
        printing = bsd
        print command = lpr -r -P'%p' %s
        lpq command = lpq -P'%p'
        lprm command = lprm -P'%p' %j
        lppause command =
        lpresume command =
        printer name =
        use client driver = No

 [homes]

 [printers]
        path = /var/spool/samba
        printable = Yes

You can easily verify which settings were implicitly added by Samba's default behavior. Remember: it may be important in your future dealings with Samba.

Note

The testparm in Samba-3 behaves differently from that in 2.2.x: used without the “-v” switch, it only shows you the settings actually written into! To see the complete configuration used, add the “-v” parameter to testparm.

Rapid Configuration Validation

Should you need to troubleshoot at any stage, please always come back to this point first and verify if testparm shows the parameters you expect. To give you a warning from personal experience, try to just comment out the load printers parameter. If your 2.2.x system behaves like mine, you'll see this:

root# grep "load printers" /etc/samba/smb.conf
        #  load printers = Yes
        # This setting is commented out!!
 
root# testparm -v /etc/samba/smb.conf | egrep "(load printers)"
        load printers = Yes

I assumed that commenting out of this setting should prevent Samba from publishing my printers, but it still did. It took some time to figure out the reason. But I am no longer fooled ... at least not by this.

root# grep -A1 "load printers" /etc/samba/smb.conf
        load printers = No
        # The above setting is what I want!
        #  load printers = Yes
        # This setting is commented out!

root# testparm -s -v smb.conf.simpleprinting | egrep "(load printers)"
        load printers = No

Only when the parameter is explicitly set to load printers = No would Samba conform with my intentions. So, my strong advice is:

  • Never rely on commented-out parameters.

  • Always set parameters explicitly as you intend them to behave.

  • Use testparm to uncover hidden settings that might not reflect your intentions.

The following is the most minimal configuration file:

root# cat /etc/samba/smb.conf-minimal
        [printers]

This example should show that you can use testparm to test any Samba configuration file. Actually, we encourage you not to change your working system (unless you know exactly what you are doing). Don't rely on the assumption that changes will only take effect after you restart smbd! This is not the case. Samba rereads it every 60 seconds and on each new client connection. You might have to face changes for your production clients that you didn't intend to apply. You will now note a few more interesting things; testparm is useful to identify what the Samba print configuration would be if you used this minimalistic configuration. Here is what you can expect to find:

root# testparm -v smb.conf-minimal | egrep "(print|lpq|spool|driver|ports|[)"
 Processing section "[printers]"
 WARNING: [printers] service MUST be printable!
 No path in service printers - using /tmp

        lpq cache time = 10
        load printers = Yes
        printcap name = /etc/printcap
        disable spoolss = No
        enumports command =
        addprinter command =
        deleteprinter command =
        show add printer wizard = Yes
        os2 driver map =
        printer admin =
        min print space = 0
        max print jobs = 1000
        printable = No
        printing = bsd
        print command = lpr -r -P%p %s
        lpq command = lpq -P%p
        printer name =
        use client driver = No

 [printers]
        printable = Yes

testparm issued two warnings:

  • We did not specify the [printers] section as printable.

  • We did not tell Samba which spool directory to use.

However, this was not fatal, and Samba will default to values that will work. Please, do not rely on this and do not use this example. This was included to encourage you to be careful to design and specify your setup to do precisely what you require. The outcome on your system may vary for some parameters given, since Samba may have been built with different compile-time options. Warning: do not put a comment sign at the end of a valid line. It will cause the parameter to be ignored (just as if you had put the comment sign at the front). At first I regarded this as a bug in my Samba versions. But the man page clearly says: Internal whitespace in a parameter value is retained verbatim. This means that a line consisting of, for example,

# This defines LPRng as the printing system
printing = lprng

will regard the whole of the string after the = sign as the value you want to define. This is an invalid value that will be ignored, and a default value will be used in its place.

Extended Printing Configuration

Extended BSD Printing Configuration shows a more verbose configuration for print-related settings in a BSD-style printing environment. What follows is a discussion and explanation of the various parameters. We chose to use BSD-style printing here because it is still the most commonly used system on legacy UNIX/Linux installations. New installations predominantly use CUPS, which is discussed in a separate chapter. The example explicitly names many parameters that do not need to be specified because they are set by default. You could use a much leaner smb.conf file, or you can use testparm or SWAT to optimize the smb.conf file to remove all parameters that are set at default.

Example 21.2. Extended BSD Printing Configuration

[global]
printing = bsd
load printers = yes
show add printer wizard = yes
printcap name = /etc/printcap
printer admin = @ntadmin, root
max print jobs = 100
lpq cache time = 20
use client driver = no
[printers]
comment = All Printers
printable = yes
path = /var/spool/samba
browseable = no
guest ok = yes
public = yes
read only = yes
writable = no
[my_printer_name]
comment = Printer with Restricted Access
path = /var/spool/samba_my_printer
printer admin = kurt
browseable = yes
printable = yes
writable = no
hosts allow = 0.0.0.0
hosts deny = turbo_xp, 10.160.50.23, 10.160.51.60
guest ok = no

This is an example configuration. You may not find all the settings that are in the configuration file that was provided by the OS vendor. Samba configuration parameters, if not explicitly set, default to a sensible value. To see all settings, as root use the testparm utility. testparm gives warnings for misconfigured settings.

Detailed Explanation Settings

The following is a discussion of the settings from Extended BSD Printing Configuration Extended BSD Printing Configuration.

The [global] Section

The [global] section is one of four special sections (along with [homes], [printers], and [print$]). The [global] contains all parameters that apply to the server as a whole. It is the place for parameters that have only a global meaning. It may also contain service-level parameters that define default settings for all other sections and shares. This way you can simplify the configuration and avoid setting the same value repeatedly. (Within each individual section or share, you may, however, override these globally set share settings and specify other values).

printing = bsd

Causes Samba to use default print commands applicable for the BSD (also known as RFC 1179 style or LPR/LPD) printing system. In general, the printing parameter informs Samba about the print subsystem it should expect. Samba supports CUPS, LPD, LPRNG, SYSV, HPUX, AIX, QNX, and PLP. Each of these systems defaults to a different print command (and other queue control commands).

Caution

The printing parameter is normally a service-level parameter. Since it is included here in the [global] section, it will take effect for all printer shares that are not defined differently. Samba-3 no longer supports the SOFTQ printing system.

load printers = yes

Tells Samba to create automatically all available printer shares. Available printer shares are discovered by scanning the printcap file. All created printer shares are also loaded for browsing. If you use this parameter, you do not need to specify separate shares for each printer. Each automatically created printer share will clone the configuration options found in the [printers] section. (The load printers = no setting will allow you to specify each UNIX printer you want to share separately, leaving out some you do not want to be publicly visible and available).

show add printer wizard = yes

Setting is normally enabled by default (even if the parameter is not specified in smb.conf). It causes the Add Printer Wizard icon to appear in the Printers folder of the Samba host's share listing (as shown in Network Neighborhood or by the net view command). To disable it, you need to explicitly set it to no (commenting it out will not suffice). The Add Printer Wizard lets you upload a printer driver to the [print$] share and associate it with a printer (if the respective queue exists before the action), or exchange a printer's driver for any other previously uploaded driver.

max print jobs = 100

Sets the upper limit to 100 print jobs being active on the Samba server at any one time. Should a client submit a job that exceeds this number, a "no more space available on server" type of error message will be returned by Samba to the client. A setting of zero (the default) means there is no limit at all.

printcap name = /etc/printcap

Tells Samba where to look for a list of available printer names. Where CUPS is used, make sure that a printcap file is written. This is controlled by the Printcap directive in the cupsd.conf file.

printer admin = @ntadmin

Members of the ntadmin group should be able to add drivers and set printer properties (ntadmin is only an example name; it needs to be a valid UNIX group name); root is implicitly always a printer admin. The @ sign precedes group names in the /etc/group. A printer admin can do anything to printers via the remote administration interfaces offered by MS-RPC (see Printing Developments Since Samba-2.2). In larger installations, the printer admin parameter is normally a per-share parameter. This permits different groups to administer each printer share.

lpq cache time = 20

Controls the cache time for the results of the lpq command. It prevents the lpq command being called too often and reduces the load on a heavily used print server.

use client driver = no

If set to yes, only takes effect for Windows NT/200x/XP clients (and not for Win 95/98/ME). Its default value is No (or False). It must not be enabled on print shares (with a yes or true setting) that have valid drivers installed on the Samba server. For more detailed explanations, see the smb.conf man page.

The [printers] Section

The printers section is the second special section. If a section with this name appears in the smb.conf, users are able to connect to any printer specified in the Samba host's printcap file, because Samba on startup then creates a printer share for every printer name it finds in the printcap file. You could regard this section as a convenient shortcut to share all printers with minimal configuration. It is also a container for settings that should apply as default to all printers. (For more details, see the smb.conf man page.) Settings inside this container must be share-level parameters.

comment = All printers

The comment is shown next to the share if a client queries the server, either via Network Neighborhood or with the net view command, to list available shares.

printable = yes

The [printers] service must be declared as printable. If you specify otherwise, smbd will refuse to load at startup. This parameter allows connected clients to open, write to, and submit spool files into the directory specified with the path parameter for this service. It is used by Samba to differentiate printer shares from file shares.

path = /var/spool/samba

Must point to a directory used by Samba to spool incoming print files. It must not be the same as the spool directory specified in the configuration of your UNIX print subsystem! The path typically points to a directory that is world writable, with the sticky bit set to it.

browseable = no

Is always set to no if printable = yes. It makes the [printer] share itself invisible in the list of available shares in a net view command or in the Explorer browse list. (You will of course see the individual printers.)

guest ok = yes

If this parameter is set to yes, no password is required to connect to the printer's service. Access will be granted with the privileges of the guest account. On many systems the guest account will map to a user named "nobody." This user will usually be found in the UNIX passwd file with an empty password, but with no valid UNIX login. On some systems the guest account might not have the privilege to be able to print. Test this by logging in as your guest user using su - guest and run a system print command like:

lpr -P printername /etc/motd

public = yes

Is a synonym for guest ok = yes. Since we have guest ok = yes, it really does not need to be here. (This leads to the interesting question, “What if I by accident have two contradictory settings for the same share?” The answer is that the last one encountered by Samba wins. testparm does not complain about different settings of the same parameter for the same share. You can test this by setting up multiple lines for the guest account parameter with different usernames, and then run testparm to see which one is actually used by Samba.)

read only = yes

Normally (for other types of shares) prevents users from creating or modifying files in the service's directory. However, in a printable service, it is always allowed to write to the directory (if user privileges allow the connection), but only via print spooling operations. Normal write operations are not permitted.

writable = no

Is a synonym for read only = yes.

Any [my_printer_name] Section

If a [my_printer_name] section appears in the smb.conf file, which includes the parameter printable = yes Samba will configure it as a printer share. Windows 9x/Me clients may have problems with connecting or loading printer drivers if the share name has more than eight characters. Do not name a printer share with a name that may conflict with an existing user or file share name. On client connection requests, Samba always tries to find file shares with that name first. If it finds one, it will connect to this and will not connect to a printer with the same name!

comment = Printer with Restricted Access

The comment says it all.

path = /var/spool/samba_my_printer

Sets the spooling area for this printer to a directory other than the default. It is not necessary to set it differently, but the option is available.

printer admin = kurt

The printer admin definition is different for this explicitly defined printer share from the general [printers] share. It is not a requirement; we did it to show that it is possible.

browseable = yes

This makes the printer browseable so the clients may conveniently find it when browsing the Network Neighborhood.

printable = yes

See Section 20.4.1.2.

writable = no

See Section 20.4.1.2.

hosts allow = 10.160.50.,10.160.51.

Here we exercise a certain degree of access control by using the hosts allow and hosts deny parameters. This is not by any means a safe bet. It is not a way to secure your printers. This line accepts all clients from a certain subnet in a first evaluation of access control.

hosts deny = turbo_xp,10.160.50.23,10.160.51.60

All listed hosts are not allowed here (even if they belong to the allowed subnets). As you can see, you could name IP addresses as well as NetBIOS hostnames here.

guest ok = no

This printer is not open for the guest account.

Print Commands

In each section defining a printer (or in the [printers] section), a print command parameter may be defined. It sets a command to process the files that have been placed into the Samba print spool directory for that printer. (That spool directory was, if you remember, set up with the path parameter). Typically, this command will submit the spool file to the Samba host's print subsystem, using the suitable system print command. But there is no requirement that this needs to be the case. For debugging or some other reason, you may want to do something completely different than print the file. An example is a command that just copies the print file to a temporary location for further investigation when you need to debug printing. If you craft your own print commands (or even develop print command shell scripts), make sure you pay attention to the need to remove the files from the Samba spool directory. Otherwise, your hard disk may soon suffer from shortage of free space.

Default UNIX System Printing Commands

You learned earlier that Samba, in most cases, uses its built-in settings for many parameters if it cannot find an explicitly stated one in its configuration file. The same is true for the print command. The default print command varies depending on the printing parameter setting. In the commands listed in Default Printing Settings , you will notice some parameters of the form %X where X is p, s, J, and so on. These letters stand for printer name, spool file, and job ID, respectively. They are explained in more detail in Default Printing Settings presents an overview of key printing options but excludes the special case of CUPS, is discussed in CUPS Printing Support.

Table 21.1. Default Printing Settings

SettingDefault Printing Commands
printing = bsd|aix|lprng|plpprint command is lpr -r -P%p %s
printing = sysv|hpuxprint command is lp -c -P%p %s; rm %s
printing = qnxprint command is lp -r -P%p -s %s
printing = bsd|aix|lprng|plplpq command is lpq -P%p
printing = sysv|hpuxlpq command is lpstat -o%p
printing = qnxlpq command is lpq -P%p
printing = bsd|aix|lprng|plplprm command is lprm -P%p %j
printing = sysv|hpuxlprm command is cancel %p-%j
printing = qnxlprm command is cancel %p-%j
printing = bsd|aix|lprng|plplppause command is lp -i %p-%j -H hold
printing = sysv|hpuxlppause command (...is empty)
printing = qnxlppause command (...is empty)
printing = bsd|aix|lprng|plplpresume command is lp -i %p-%j -H resume
printing = sysv|hpuxlpresume command (...is empty)
printing = qnxlpresume command (...is empty)

For printing = CUPS, if Samba is compiled against libcups, it uses the CUPS API to submit jobs. (It is a good idea also to set printcap = cups in case your cupsd.conf is set to write its autogenerated printcap file to an unusual place). Otherwise, Samba maps to the System V printing commands with the -oraw option for printing; that is, it uses lp -c -d%p -oraw; rm %s. With printing = cups, and if Samba is compiled against libcups, any manually set print command will be ignored!

Custom Print Commands

After a print job has finished spooling to a service, the print command will be used by Samba via a system() call to process the spool file. Usually the command specified will submit the spool file to the host's printing subsystem. But there is no requirement at all that this must be the case. The print subsystem may not remove the spool file on its own, so whatever command you specify, you should ensure that the spool file is deleted after it has been processed.

There is no difficulty with using your own customized print commands with the traditional printing systems. However, if you do not wish to roll your own, you should be well informed about the default built-in commands that Samba uses for each printing subsystem (see Default Printing Settings). In all the commands listed in the last paragraphs, you see parameters of the form %X. These are macros, or shortcuts, used as placeholders for the names of real objects. At the time of running a command with such a placeholder, Samba will insert the appropriate value automatically. Print commands can handle all Samba macro substitutions. In regard to printing, the following ones do have special relevance:

  • %s, %f the path to the spool file name.

  • %p the appropriate printer name.

  • %J the job name as transmitted by the client.

  • %c the number of printed pages of the spooled job (if known).

  • %z the size of the spooled print job (in bytes).

The print command must contain at least one occurrence of %s or %f. The %p is optional. If no printer name is supplied, the %p will be silently removed from the print command. In this case, the job is sent to the default printer.

If specified in the [global] section, the print command given will be used for any printable service that does not have its own print command specified. If there is neither a specified print command for a printable service nor a global print command, spool files will be created but not processed! Most importantly, print files will not be removed, so they will consume disk space.

Printing may fail on some UNIX systems when using the nobody account. If this happens, create an alternative guest account and give it the privilege to print. Set up this guest account in the [global] section with the guest account parameter.

You can form quite complex print commands. You need to realize that print commands are just passed to a UNIX shell. The shell is able to expand the included environment variables as usual. (The syntax to include a UNIX environment variable $variable in the Samba print command is %$variable.) To give you a working print command example, the following will log a print job to /tmp/print.log, print the file, then remove it. The semicolon (“;” is the usual separator for commands in shell scripts:

print command = echo Printing %s >> /tmp/print.log; lpr -P %p %s; rm %s

You may have to vary your own command considerably from this example depending on how you normally print files on your system. The default for the print command parameter varies depending on the setting of the printing parameter. Another example is:

print command = /usr/local/samba/bin/myprintscript %p %s

Printing Developments Since Samba-2.2

Prior to Samba-2.2.x, print server support for Windows clients was limited to LanMan printing calls. This is the same protocol level as Windows 9x/Me PCs offer when they share printers. Beginning with the 2.2.0 release, Samba started to support the native Windows NT printing mechanisms. These are implemented via MS-RPC (Remote Procedure Calls). MS-RPCs use the SPOOLSS named pipe for all printing.

The additional functionality provided by the new SPOOLSS support includes:

  • Support for downloading printer driver files to Windows 95/98/NT/2000 clients upon demand (Point'n'Print).

  • Uploading of printer drivers via the Windows NT Add Printer Wizard (APW) or the Imprints tool set.

  • Support for the native MS-RPC printing calls such as StartDocPrinter, EnumJobs(), and so on. (See the MSDN documentation for more information on the Win32 printing API).

  • Support for NT Access Control Lists (ACL) on printer objects.

  • Improved support for printer queue manipulation through the use of internal databases for spooled job information (implemented by various *.tdb files).

A benefit of updating is that Samba-3 is able to publish its printers to Active Directory (or LDAP).

A fundamental difference exists between MS Windows NT print servers and Samba operation. Windows NT permits the installation of local printers that are not shared. This is an artifact of the fact that any Windows NT machine (server or client) may be used by a user as a workstation. Samba will publish all printers that are made available, either by default or by specific declaration via printer-specific shares.

Windows NT/200x/XP Professional clients do not have to use the standard SMB printer share; they can print directly to any printer on another Windows NT host using MS-RPC. This, of course, assumes that the client has the necessary privileges on the remote host that serves the printer resource. The default permissions assigned by Windows NT to a printer gives the print permissions to the well-known Everyone group. (The older clients of type Windows 9x/Me can only print to shared printers.)

Point'n'Print Client Drivers on Samba Servers

There is much confusion about what all this means. The question is often asked, “Is it or is it not necessary for printer drivers to be installed on a Samba host in order to support printing from Windows clients?” The answer to this is no, it is not necessary.

Windows NT/2000 clients can, of course, also run their APW to install drivers locally (which then connect to a Samba-served print queue). This is the same method used by Windows 9x/Me clients. (However, a bug existed in Samba 2.2.0 that made Windows NT/2000 clients require that the Samba server possess a valid driver for the printer. This was fixed in Samba 2.2.1).

But it is a new capability to install the printer drivers into the [print$] share of the Samba server, and a big convenience, too. Then all clients (including 95/98/ME) get the driver installed when they first connect to this printer share. The uploading or depositing of the driver into this [print$] share and the following binding of this driver to an existing Samba printer share can be achieved by different means:

  • Running the APW on an NT/200x/XP Professional client (this does not work from 95/98/ME clients).

  • Using the Imprints toolset.

  • Using the smbclient and rpcclient command-line tools.

  • Using cupsaddsmb (only works for the CUPS printing system, not for LPR/LPD, LPRng, and so on).

Samba does not use these uploaded drivers in any way to process spooled files. These drivers are utilized entirely by the clients who download and install them via the “Point'n'Print” mechanism supported by Samba. The clients use these drivers to generate print files in the format the printer (or the UNIX print system) requires. Print files received by Samba are handed over to the UNIX printing system, which is responsible for all further processing, as needed.

The Obsoleted [printer$] Section

Versions of Samba prior to 2.2 made it possible to use a share named [printer$]. This name was taken from the same named service created by Windows 9x/Me clients when a printer was shared by them. Windows 9x/Me printer servers always have a [printer$] service that provides read-only access (with no password required) to support printer driver downloads. However, Samba's initial implementation allowed for a parameter named printer driver location to be used on a per-share basis. This specified the location of the driver files associated with that printer. Another parameter named printer driver provided a means of defining the printer driver name to be sent to the client.

These parameters, including the printer driver file parameter, are now removed and cannot be used in installations of Samba-3. The share name [print$] is now used for the location of downloadable printer drivers. It is taken from the [print$] service created by Windows NT PCs when a printer is shared by them. Windows NT print servers always have a [print$] service that provides read-write access (in the context of its ACLs) to support printer driver downloads and uploads. This does not mean Windows 9x/Me clients are now thrown aside. They can use Samba's [print$] share support just fine.

Creating the [print$] Share

In order to support the uploading and downloading of printer driver files, you must first configure a file share named [print$]. The public name of this share is hard coded in the MS Windows clients. It cannot be renamed, since Windows clients are programmed to search for a service of exactly this name if they want to retrieve printer driver files.

You should modify the server's file to add the global parameters and create the [print$] file share (of course, some of the parameter values, such as path, are arbitrary and should be replaced with appropriate values for your site). See [print\$] Example.

Example 21.3. [print$] Example

[global]
# members of the ntadmin group should be able to add drivers and set
# printer properties. root is implicitly always a 'printer admin'.
printer admin = @ntadmin
# ...
[printers]
# ...
[print$]
comment = Printer Driver Download Area
path = /etc/samba/drivers
browseable = yes
guest ok = yes
read only = yes
write list = @ntadmin, root

Of course, you also need to ensure that the directory named by the path parameter exists on the UNIX file system.

[print$] Stanza Parameters

The [print$] is a special section in smb.conf. It contains settings relevant to potential printer driver download and is used by Windows clients for local print driver installation. The following parameters are frequently needed in this share section:

comment = Printer Driver Download Area

The comment appears next to the share name if it is listed in a share list (usually Windows clients will not see it, but it will also appear up in a smbclient -L sambaserver output).

path = /etc/samba/printers

The path to the location of the Windows driver file deposit from the UNIX point of view.

browseable = no

Makes the [print$] share invisible to clients from the Network Neighborhood. By excuting from a cmd shell:

C:\>  net use g:\\sambaserver\print$

you can still mount it from any client. This can also be done from the Connect network drive menu> from Windows Explorer.

guest ok = yes

Gives read-only access to this share for all guest users. Access may be granted to download and install printer drivers on clients. The requirement for guest ok = yes depends on how your site is configured. If users will be guaranteed to have an account on the Samba host, then this is a non-issue.

Note

If all your Windows NT users are guaranteed to be authenticated by the Samba server (for example, if Samba authenticates via an NT domain server and the user has already been validated by the domain controller in order to log on to the Windows NT session), then guest access is not necessary. Of course, in a workgroup environment where you just want to print without worrying about silly accounts and security, then configure the share for guest access. You should consider adding map to guest = Bad User in the [global] section as well. Make sure you understand what this parameter does before using it.

read only = yes

Because we do not want everybody to upload driver files (or even change driver settings), we tagged this share as not writable.

write list = @ntadmin, root

The [print$] was made read-only by the previous setting so we should create a write list entry also. UNIX groups are denoted with a leading “@” character. Users listed here are allowed write-access (as an exception to the general public's read-only access), which they need to update files on the share. Normally, you will want to name only administrative-level user account in this setting. Check the file system permissions to make sure these accounts can copy files to the share. If this is a non-root account, then the account should also be mentioned in the global printer admin parameter. See the smb.conf man page for more information on configuring file shares.

The [print$] Share Directory

In order for a Windows NT print server to support the downloading of driver files by multiple client architectures, you must create several subdirectories within the [print$] service (i.e., the UNIX directory named by the path parameter). These correspond to each of the supported client architectures. Samba follows this model as well. Just like the name of the [print$] share itself, the subdirectories must be exactly the names listed below (you may leave out the subdirectories of architectures you do not need to support).

Therefore, create a directory tree below the [print$] share for each architecture you wish to support like this:

[print$]--+
          |--W32X86           # serves drivers to Windows NT x86
          |--WIN40            # serves drivers to Windows 95/98
          |--W32ALPHA         # serves drivers to Windows NT Alpha_AXP
          |--W32MIPS          # serves drivers to Windows NT R4000
          |--W32PPC           # serves drivers to Windows NT PowerPC

Required Permissions

In order to add a new driver to your Samba host, one of two conditions must hold true:

  • The account used to connect to the Samba host must have a UID of 0 (i.e., a root account).

  • The account used to connect to the Samba host must be named in the printer admin list.

Of course, the connected account must still have write access to add files to the subdirectories beneath [print$]. Remember that all file shares are set to “read-only” by default.

Once you have created the required [print$] service and associated subdirectories, go to a Windows NT 4.0/200x/XP client workstation. Open Network Neighborhood or My Network Places and browse for the Samba host. Once you have located the server, navigate to its Printers and Faxes folder. You should see an initial listing of printers that matches the printer shares defined on your Samba host.

Installing Drivers into [print$]

Have you successfully created the [print$] share in smb.conf, and have you forced Samba to reread its smb.conf file? Good. But you are not yet ready to use the new facility. The client driver files need to be installed into this share. So far, it is still an empty share. Unfortunately, it is not enough to just copy the driver files over. They need to be correctly installed so that appropriate records for each driver will exist in the Samba internal databases so it can provide the correct drivers as they are requested from MS Windows clients. And that is a bit tricky, to say the least. We now discuss two alternative ways to install the drivers into [print$]:

  • Using the Samba command-line utility rpcclient with its various subcommands (here, adddriver and setdriver) from any UNIX workstation.

  • Running a GUI (Printer Properties and Add Printer Wizard) from any Windows NT/200x/XP client workstation.

The latter option is probably the easier one (even if the process may seem a little bit weird at first).

Add Printer Wizard Driver Installation

The printers initially listed in the Samba host's Printers folder accessed from a client's Explorer will have no real printer driver assigned to them. By default this driver name is set to a null string. This must be changed now. The local Add Printer Wizard (APW), run from NT/2000/XP clients, will help us in this task.

Installation of a valid printer driver is not straightforward. You must attempt to view the printer properties for the printer to which you want the driver assigned. Open Windows Explorer, open Network Neighborhood, browse to the Samba host, open Samba's Printers folder, right-click on the printer icon, and select Properties.... You are now trying to view printer and driver properties for a queue that has this default NULL driver assigned. This will result in the following error message: “ Device settings cannot be displayed. The driver for the specified printer is not installed, only spooler properties will be displayed. Do you want to install the driver now?

Do not click on Yes! Instead, click on No in the error dialog. Now you will be presented with the printer properties window. From here, the way to assign a driver to a printer is open. You now have the choice of:

  • Select a driver from the pop-up list of installed drivers. Initially this list will be empty.

  • Click on New Driver to install a new printer driver (which will start up the APW).

Once the APW is started, the procedure is exactly the same as the one you are familiar with in Windows (we assume here that you are familiar with the printer driver installations procedure on Windows NT). Make sure your connection is, in fact, set up as a user with printer admin privileges (if in doubt, use smbstatus to check for this). If you wish to install printer drivers for client operating systems other than Windows NT x86, you will need to use the Sharing tab of the printer properties dialog.

Assuming you have connected with an administrative (or root) account (as named by the printer admin parameter), you will also be able to modify other printer properties such as ACLs and default device settings using this dialog. For the default device settings, please consider the advice given further in Installing Print Drivers Using rpcclient.

Installing Print Drivers Using rpcclient

The second way to install printer drivers into [print$] and set them up in a valid way is to do it from the UNIX command line. This involves four distinct steps:

  1. Gather information about required driver files and collect the files.

  2. Deposit the driver files into the [print$] share's correct subdirectories (possibly by using smbclient).

  3. Run the rpcclient command-line utility once with the adddriver subcommand.

  4. Run rpcclient a second time with the setdriver subcommand.

We provide detailed hints for each of these steps in the paragraphs that follow.

Identifying Driver Files

To find out about the driver files, you have two options. You can check the contents of the driver CDROM that came with your printer. Study the *.inf files located on the CD-ROM. This may not be possible, since the *.inf file might be missing. Unfortunately, vendors have now started to use their own installation programs. These installations packages are often in some Windows platform archive format. Additionally, the files may be re-named during the installation process. This makes it extremely difficult to identify the driver files required.

Then you have the second option. Install the driver locally on a Windows client and investigate which filenames and paths it uses after they are installed. (You need to repeat this procedure for every client platform you want to support. We show it here for the W32X86 platform only, a name used by Microsoft for all Windows NT/200x/XP clients.)

A good method to recognize the driver files is to print the test page from the driver's Properties dialog (General tab). Then look at the list of driver files named on the printout. You'll need to recognize what Windows (and Samba) are calling the Driver File, Data File, Config File, Help File, and (optionally) Dependent Driver Files (this may vary slightly for Windows NT). You need to note all filenames for the next steps.

Another method to quickly test the driver filenames and related paths is provided by the rpcclient utility. Run it with enumdrivers or with the getdriver subcommand, each at the 3 info level. In the following example, TURBO_XP is the name of the Windows PC (in this case it was a Windows XP Professional laptop). I installed the driver locally to TURBO_XP from a Samba server called KDE-BITSHOP. We could run an interactive rpcclient session; then we would get an rpcclient /> prompt and would type the subcommands at this prompt. This is left as a good exercise for you. For now, we use rpcclient with the -c parameter to execute a single subcommand line and exit again. This is the method you use if you want to create scripts to automate the procedure for a large number of printers and drivers. Note the different quotation marks used to overcome the different spaces between words:

root# rpcclient -U'Danka%xxxx' -c \
	'getdriver "Heidelberg Digimaster 9110 (PS)" 3' TURBO_XP
cmd = getdriver "Heidelberg Digimaster 9110 (PS)" 3

[Windows NT x86]
Printer Driver Info 3:
  Version: [2]
  Driver Name: [Heidelberg Digimaster 9110 (PS)]
  Architecture: [Windows NT x86]
  Driver Path: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01_de.DLL]
  Datafile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.ppd]
  Configfile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01U_de.DLL]
  Helpfile: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01U_de.HLP]
  
  Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.DLL]
  Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.INI]
  Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.dat]
  Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.cat]
  Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.def]
  Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.hre]
  Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.vnd]
  Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\Hddm91c1_de.hlp]
  Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01Aux.dll]
  Dependentfiles: [C:\WINNT\System32\spool\DRIVERS\W32X86\2\HDNIS01_de.NTF]
  
  Monitorname: []
  Defaultdatatype: []

You may notice that this driver has quite a large number of Dependent files (there are worse cases, however). Also, strangely, the Driver File is tagged here Driver Path. We do not yet have support for the so-called WIN40 architecture installed. This name is used by Microsoft for the Windows 9x/Me platforms. If we want to support these, we need to install the Windows 9x/Me driver files in addition to those for W32X86 (i.e., the Windows NT 2000/XP clients) onto a Windows PC. This PC can also host the Windows 9x/Me drivers, even if it runs on Windows NT, 2000, or XP.

Since the [print$] share is usually accessible through the Network Neighborhood, you can also use the UNC notation from Windows Explorer to poke at it. The Windows 9x/Me driver files will end up in subdirectory 0 of the WIN40 directory. The full path to access them is \\WINDOWSHOST\print$\WIN40\0\.

Note

More recent drivers on Windows 2000 and Windows XP are installed into the “3” subdirectory instead of the “2”. The version 2 of drivers, as used in Windows NT, were running in kernel mode. Windows 2000 changed this. While it still can use the kernel mode drivers (if this is enabled by the Admin), its native mode for printer drivers is user mode execution. This requires drivers designed for this purpose. These types of drivers install into the “3” subdirectory.

Obtaining Driver Files from Windows Client [print$] Shares

Now we need to collect all the driver files we identified in our previous step. Where do we get them from? Well, why not retrieve them from the very PC and the same [print$] share that we investigated in our last step to identify the files? We can use smbclient to do this. We will use the paths and names that were leaked to us by getdriver. The listing is edited to include line breaks for readability:

root# smbclient //TURBO_XP/print\$ -U'Danka%xxxx' \ 
   -c 'cd W32X86/2;mget HD*_de.* hd*ppd Hd*_de.* Hddm*dll HDN*Aux.DLL'

added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
Got a positive name query response from 10.160.50.8 ( 10.160.50.8 )
Domain=[DEVELOPMENT] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
Get file Hddm91c1_de.ABD? n
Get file Hddm91c1_de.def? y
getting file \W32X86\2\Hddm91c1_de.def of size 428 as Hddm91c1_de.def
Get file Hddm91c1_de.DLL? y
getting file \W32X86\2\Hddm91c1_de.DLL of size 876544 as Hddm91c1_de.DLL
[...]

After this command is complete, the files are in our current local directory. You probably have noticed that this time we passed several commands to the -c parameter, separated by semicolons. This ensures that all commands are executed in sequence on the remote Windows server before smbclient exits again.

Remember to repeat the procedure for the WIN40 architecture should you need to support Windows 9x/Me/XP clients. Remember too, the files for these architectures are in the WIN40/0/ subdirectory. Once this is complete, we can run smbclient. . .put to store the collected files on the Samba server's [print$] share.

Installing Driver Files into [print$]

We are now going to locate the driver files into the [print$] share. Remember, the UNIX path to this share has been defined previously in your smb.conf file. You also have created subdirectories for the different Windows client types you want to support. If, for example, your [print$] share maps to the UNIX path /etc/samba/drivers/, your driver files should now go here:

  • For all Windows NT, 2000, and XP clients, /etc/samba/drivers/W32X86/ but not (yet) into the 2 subdirectory.

  • For all Windows 95, 98, and Me clients, /etc/samba/drivers/WIN40/ but not (yet) into the 0 subdirectory.

We again use smbclient to transfer the driver files across the network. We specify the same files and paths as were leaked to us by running getdriver against the original Windows install. However, now we are going to store the files into a Samba/UNIX print server's [print$] share.

root# smbclient //SAMBA-CUPS/print\$ -U'root%xxxx' -c \
  'cd W32X86; put HDNIS01_de.DLL; \
  put Hddm91c1_de.ppd; put HDNIS01U_de.DLL;        \
  put HDNIS01U_de.HLP; put Hddm91c1_de.DLL;        \
  put Hddm91c1_de.INI; put Hddm91c1KMMin.DLL;      \
  put Hddm91c1_de.dat; put Hddm91c1_de.dat;        \
  put Hddm91c1_de.def; put Hddm91c1_de.hre;        \
  put Hddm91c1_de.vnd; put Hddm91c1_de.hlp;        \
  put Hddm91c1_de_reg.HLP; put HDNIS01Aux.dll;     \
  put HDNIS01_de.NTF'

added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
Got a positive name query response from 10.160.51.162 ( 10.160.51.162 )
Domain=[CUPS-PRINT] OS=[UNIX] Server=[Samba 2.2.7a]
putting file HDNIS01_de.DLL as \W32X86\HDNIS01_de.DLL
putting file Hddm91c1_de.ppd as \W32X86\Hddm91c1_de.ppd
putting file HDNIS01U_de.DLL as \W32X86\HDNIS01U_de.DLL
putting file HDNIS01U_de.HLP as \W32X86\HDNIS01U_de.HLP
putting file Hddm91c1_de.DLL as \W32X86\Hddm91c1_de.DLL
putting file Hddm91c1_de.INI as \W32X86\Hddm91c1_de.INI
putting file Hddm91c1KMMin.DLL as \W32X86\Hddm91c1KMMin.DLL
putting file Hddm91c1_de.dat as \W32X86\Hddm91c1_de.dat
putting file Hddm91c1_de.dat as \W32X86\Hddm91c1_de.dat
putting file Hddm91c1_de.def as \W32X86\Hddm91c1_de.def
putting file Hddm91c1_de.hre as \W32X86\Hddm91c1_de.hre
putting file Hddm91c1_de.vnd as \W32X86\Hddm91c1_de.vnd
putting file Hddm91c1_de.hlp as \W32X86\Hddm91c1_de.hlp
putting file Hddm91c1_de_reg.HLP as \W32X86\Hddm91c1_de_reg.HLP
putting file HDNIS01Aux.dll as \W32X86\HDNIS01Aux.dll
putting file HDNIS01_de.NTF as \W32X86\HDNIS01_de.NTF

Whew that was a lot of typing! Most drivers are a lot smaller many have only three generic PostScript driver files plus one PPD. While we did retrieve the files from the 2 subdirectory of the W32X86 directory from the Windows box, we do not put them (for now) in this same subdirectory of the Samba box. This relocation will automatically be done by the adddriver command, which we will run shortly (and do not forget to also put the files for the Windows 9x/Me architecture into the WIN40/ subdirectory should you need them).

smbclient to Confirm Driver Installation

For now we verify that our files are there. This can be done with smbclient, too (but, of course, you can log in via SSH also and do this through a standard UNIX shell access):

root# smbclient //SAMBA-CUPS/print\$ -U 'root%xxxx' \
	-c 'cd W32X86; pwd; dir; cd 2; pwd; dir'
 added interface ip=10.160.51.60 bcast=10.160.51.255 nmask=255.255.252.0
Got a positive name query response from 10.160.51.162 ( 10.160.51.162 )
Domain=[CUPS-PRINT] OS=[UNIX] Server=[Samba 2.2.8a]

Current directory is \\SAMBA-CUPS\print$\W32X86\
.                                  D        0  Sun May  4 03:56:35 2003
..                                 D        0  Thu Apr 10 23:47:40 2003
2                                   D        0  Sun May  4 03:56:18 2003
HDNIS01Aux.dll                      A    15356  Sun May  4 03:58:59 2003
Hddm91c1KMMin.DLL                   A    46966  Sun May  4 03:58:59 2003
HDNIS01_de.DLL                      A   434400  Sun May  4 03:58:59 2003
HDNIS01_de.NTF                      A   790404  Sun May  4 03:56:35 2003
Hddm91c1_de.DLL                     A   876544  Sun May  4 03:58:59 2003
Hddm91c1_de.INI                     A      101  Sun May  4 03:58:59 2003
Hddm91c1_de.dat                     A     5044  Sun May  4 03:58:59 2003
Hddm91c1_de.def                     A      428  Sun May  4 03:58:59 2003
Hddm91c1_de.hlp                     A    37699  Sun May  4 03:58:59 2003
Hddm91c1_de.hre                     A   323584  Sun May  4 03:58:59 2003
Hddm91c1_de.ppd                     A    26373  Sun May  4 03:58:59 2003
Hddm91c1_de.vnd                     A    45056  Sun May  4 03:58:59 2003
HDNIS01U_de.DLL                     A   165888  Sun May  4 03:58:59 2003
HDNIS01U_de.HLP                     A    19770  Sun May  4 03:58:59 2003
Hddm91c1_de_reg.HLP                 A   228417  Sun May  4 03:58:59 2003
              40976 blocks of size 262144. 709 blocks available

Current directory is \\SAMBA-CUPS\print$\W32X86\2\
.                                  D        0  Sun May  4 03:56:18 2003
..                                 D        0  Sun May  4 03:56:35 2003
ADOBEPS5.DLL                        A   434400  Sat May  3 23:18:45 2003
laserjet4.ppd                       A     9639  Thu Apr 24 01:05:32 2003
ADOBEPSU.DLL                        A   109568  Sat May  3 23:18:45 2003
ADOBEPSU.HLP                        A    18082  Sat May  3 23:18:45 2003
PDFcreator2.PPD                     A    15746  Sun Apr 20 22:24:07 2003
              40976 blocks of size 262144. 709 blocks available

Notice that there are already driver files present in the 2 subdirectory (probably from a previous installation). Once the files for the new driver are there too, you are still a few steps away from being able to use them on the clients. The only thing you could do now is retrieve them from a client just like you retrieve ordinary files from a file share, by opening print$ in Windows Explorer. But that wouldn't install them per Point'n'Print. The reason is that Samba does not yet know that these files are something special, namely printer driver files, and it does not know to which print queue(s) these driver files belong.

Running rpcclient with adddriver

Next, you must tell Samba about the special category of the files you just uploaded into the [print$] share. This is done by the adddriver command. It will prompt Samba to register the driver files into its internal TDB database files. The following command and its output has been edited for readability:

root# rpcclient -Uroot%xxxx -c 'adddriver "Windows NT x86" \
  "dm9110:HDNIS01_de.DLL: \
  Hddm91c1_de.ppd:HDNIS01U_de.DLL:HDNIS01U_de.HLP:   \
  NULL:RAW:Hddm91c1_de.DLL,Hddm91c1_de.INI,          \
  Hddm91c1_de.dat,Hddm91c1_de.def,Hddm91c1_de.hre,   \
  Hddm91c1_de.vnd,Hddm91c1_de.hlp,Hddm91c1KMMin.DLL, \
  HDNIS01Aux.dll,HDNIS01_de.NTF,                     \
  Hddm91c1_de_reg.HLP' SAMBA-CUPS

cmd = adddriver "Windows NT x86" \
  "dm9110:HDNIS01_de.DLL:Hddm91c1_de.ppd:HDNIS01U_de.DLL:   \
  HDNIS01U_de.HLP:NULL:RAW:Hddm91c1_de.DLL,Hddm91c1_de.INI, \
  Hddm91c1_de.dat,Hddm91c1_de.def,Hddm91c1_de.hre,          \
  Hddm91c1_de.vnd,Hddm91c1_de.hlp,Hddm91c1KMMin.DLL,        \
  HDNIS01Aux.dll,HDNIS01_de.NTF,Hddm91c1_de_reg.HLP"

Printer Driver dm9110 successfully installed.

After this step, the driver should be recognized by Samba on the print server. You need to be very careful when typing the command. Don't exchange the order of the fields. Some changes would lead to an NT_STATUS_UNSUCCESSFUL error message. These become obvious. Other changes might install the driver files successfully but render the driver unworkable. So take care! Hints about the syntax of the adddriver command are in the man page. provides a more detailed description, should you need it.

Checking adddriver Completion

One indication for Samba's recognition of the files as driver files is the successfully installed message. Another one is the fact that our files have been moved by the adddriver command into the 2 subdirectory. You can check this again with smbclient:

root# smbclient //SAMBA-CUPS/print\$ -Uroot%xx \
	-c 'cd W32X86;dir;pwd;cd 2;dir;pwd'
 added interface ip=10.160.51.162 bcast=10.160.51.255 nmask=255.255.252.0
 Domain=[CUPS-PRINT] OS=[UNIX] Server=[Samba 2.2.7a]

  Current directory is \\SAMBA-CUPS\print$\W32X86\
  .                                  D        0  Sun May  4 04:32:48 2003
  ..                                 D        0  Thu Apr 10 23:47:40 2003
  2                                   D        0  Sun May  4 04:32:48 2003
                40976 blocks of size 262144. 731 blocks available 

  Current directory is \\SAMBA-CUPS\print$\W32X86\2\
  .                                  D        0  Sun May  4 04:32:48 2003
  ..                                 D        0  Sun May  4 04:32:48 2003
  DigiMaster.PPD                      A   148336  Thu Apr 24 01:07:00 2003
  ADOBEPS5.DLL                        A   434400  Sat May  3 23:18:45 2003
  laserjet4.ppd                       A     9639  Thu Apr 24 01:05:32 2003
  ADOBEPSU.DLL                        A   109568  Sat May  3 23:18:45 2003
  ADOBEPSU.HLP                        A    18082  Sat May  3 23:18:45 2003
  PDFcreator2.PPD                     A    15746  Sun Apr 20 22:24:07 2003
  HDNIS01Aux.dll                      A    15356  Sun May  4 04:32:18 2003
  Hddm91c1KMMin.DLL                   A    46966  Sun May  4 04:32:18 2003
  HDNIS01_de.DLL                      A   434400  Sun May  4 04:32:18 2003
  HDNIS01_de.NTF                      A   790404  Sun May  4 04:32:18 2003
  Hddm91c1_de.DLL                     A   876544  Sun May  4 04:32:18 2003
  Hddm91c1_de.INI                     A      101  Sun May  4 04:32:18 2003
  Hddm91c1_de.dat                     A     5044  Sun May  4 04:32:18 2003
  Hddm91c1_de.def                     A      428  Sun May  4 04:32:18 2003
  Hddm91c1_de.hlp                     A    37699  Sun May  4 04:32:18 2003
  Hddm91c1_de.hre                     A   323584  Sun May  4 04:32:18 2003
  Hddm91c1_de.ppd                     A    26373  Sun May  4 04:32:18 2003
  Hddm91c1_de.vnd                     A    45056  Sun May  4 04:32:18 2003
  HDNIS01U_de.DLL                     A   165888  Sun May  4 04:32:18 2003
  HDNIS01U_de.HLP                     A    19770  Sun May  4 04:32:18 2003
  Hddm91c1_de_reg.HLP                 A   228417  Sun May  4 04:32:18 2003
                40976 blocks of size 262144. 731 blocks available

Another verification is that the timestamp of the printing TDB files is now updated (and possibly their file size has increased).

Check Samba for Driver Recognition

Now the driver should be registered with Samba. We can easily verify this and will do so in a moment. However, this driver is not yet associated with a particular printer. We may check the driver status of the files by at least three methods:

  • From any Windows client browse Network Neighborhood, find the Samba host, and open the Samba Printers and Faxes folder. Select any printer icon, right-click and select the printer Properties. Click the Advanced tab. Here is a field indicating the driver for that printer. A drop-down menu allows you to change that driver (be careful not to do this unwittingly). You can use this list to view all drivers known to Samba. Your new one should be among them. (Each type of client will see only its own architecture's list. If you do not have every driver installed for each platform, the list will differ if you look at it from Windows95/98/ME or Windows NT/2000/XP.)

  • From a Windows 200x/XP client (not Windows NT) browse Network Neighborhood, search for the Samba server, open the server's Printers folder, and right-click on the white background (with no printer highlighted). Select Server Properties. On the Drivers tab you will see the new driver listed. This view enables you to also inspect the list of files belonging to that driver (this does not work on Windows NT, but only on Windows 2000 and Windows XP; Windows NT does not provide the Drivers tab). An alternative and much quicker method for Windows 2000/XP to start this dialog is by typing into a DOS box (you must of course adapt the name to your Samba server instead of SAMBA-CUPS):

    	rundll32 printui.dll,PrintUIEntry /s /t2 /n\\SAMBA-CUPS
    	

  • From a UNIX prompt, run this command (or a variant thereof), where SAMBA-CUPS is the name of the Samba host and xxxx represents the actual Samba password assigned to root:

    	rpcclient -U'root%xxxx' -c 'enumdrivers' SAMBA-CUPS
    	

    You will see a listing of all drivers Samba knows about. Your new one should be among them. But it is only listed under the [Windows NT x86] heading, not under [Windows 4.0], since you didn't install that part. Or did you? In our example it is named dm9110. Note that the third column shows the other installed drivers twice, one time for each supported architecture. Our new driver only shows up for Windows NT 4.0 or 2000. To have it present for Windows 95, 98, and Me, you'll have to repeat the whole procedure with the WIN40 architecture and subdirectory.

Specific Driver Name Flexibility

You can name the driver as you like. If you repeat the adddriver step with the same files as before but with a different driver name, it will work the same:

root# rpcclient -Uroot%xxxx         \
  -c 'adddriver "Windows NT x86"                     \
  "mydrivername:HDNIS01_de.DLL:              \
  Hddm91c1_de.ppd:HDNIS01U_de.DLL:HDNIS01U_de.HLP:   \
  NULL:RAW:Hddm91c1_de.DLL,Hddm91c1_de.INI,          \
  Hddm91c1_de.dat,Hddm91c1_de.def,Hddm91c1_de.hre,   \
  Hddm91c1_de.vnd,Hddm91c1_de.hlp,Hddm91c1KMMin.DLL, \
  HDNIS01Aux.dll,HDNIS01_de.NTF,Hddm91c1_de_reg.HLP' SAMBA-CUPS
  

cmd = adddriver "Windows NT x86" \
 "mydrivername:HDNIS01_de.DLL:Hddm91c1_de.ppd:HDNIS01U_de.DLL:\
  HDNIS01U_de.HLP:NULL:RAW:Hddm91c1_de.DLL,Hddm91c1_de.INI,           \
  Hddm91c1_de.dat,Hddm91c1_de.def,Hddm91c1_de.hre,                    \
  Hddm91c1_de.vnd,Hddm91c1_de.hlp,Hddm91c1KMMin.DLL,                  \
  HDNIS01Aux.dll,HDNIS01_de.NTF,Hddm91c1_de_reg.HLP"

Printer Driver mydrivername successfully installed.

You will be able to bind that driver to any print queue (however, you are responsible that you associate drivers to queues that make sense with respect to target printers). You cannot run the rpcclient adddriver command repeatedly. Each run consumes the files you had put into the [print$] share by moving them into the respective subdirectories, so you must execute an smbclient ... put command before each rpcclient ... adddriver command.

Running rpcclient with setdriver

Samba needs to know which printer owns which driver. Create a mapping of the driver to a printer, and store this information in Samba's memory, the TDB files. The rpcclient setdriver command achieves exactly this:

root# rpcclient -U'root%xxxx' -c 'setdriver dm9110 mydrivername' SAMBA-CUPS
 cmd = setdriver dm9110 mydrivername

Successfully set dm9110 to driver mydrivername.

Ah, no, I did not want to do that. Repeat, this time with the name I intended:

root# rpcclient -U'root%xxxx' -c 'setdriver dm9110 dm9110' SAMBA-CUPS
 cmd = setdriver dm9110 dm9110
Successfully set dm9110 to driver dm9110.

The syntax of the command is:

rpcclient -U'root%sambapassword' -c 'setdriver printername \
 drivername' SAMBA-Hostname. 

Now we have done most of the work, but not all of it.

Note

The setdriver command will only succeed if the printer is already known to Samba. A bug in 2.2.x prevented Samba from recognizing freshly installed printers. You had to restart Samba, or at least send an HUP signal to all running smbd processes to work around this: kill -HUP `pidof smbd`.

Client Driver Installation Procedure

As Don Quixote said, “The proof of the pudding is in the eating.” The proof for our setup lies in the printing. So let's install the printer driver onto the client PCs. This is not as straightforward as it may seem. Read on.

First Client Driver Installation

Especially important is the installation onto the first client PC (for each architectural platform separately). Once this is done correctly, all further clients are easy to set up and shouldn't need further attention. What follows is a description for the recommended first procedure. You now work from a client workstation. You should check that your connection is not unwittingly mapped to bad user nobody. In a DOS box type:

net use \\SAMBA-SERVER\print$ /user:root

Replace root, if needed, by another valid printer admin user as given in the definition. Should you already be connected as a different user, you will get an error message. There is no easy way to get rid of that connection, because Windows does not seem to know a concept of logging off from a share connection (do not confuse this with logging off from the local workstation; that is a different matter). On Windows NT/200x, you can force a logoff from all smb/cifs connections by restarting the workstation service. You can try to close all Windows file explorers and Internet Explorer for Windows. As a last resort, you may have to reboot. Make sure there is no automatic reconnection set up. It may be easier to go to a different workstation and try from there. After you have made sure you are connected as a printer admin user (you can check this with the smbstatus command on Samba), do this from the Windows workstation:

  1. Open Network Neighborhood.

  2. Browse to Samba server.

  3. Open its Printers and Faxes folder.

  4. Highlight and right-click on the printer.

  5. Select Connect (for Windows NT4/200x it is possibly Install).

A new printer (named printername on Samba server) should now have appeared in your local Printer folder (check Start -> Settings -> Control Panel -> Printers and Faxes).

Most likely you are tempted to try to print a test page. After all, you now can open the printer properties, and on the General tab there is a button offering to do just that. But chances are that you get an error message saying "Unable to print Test Page." The reason might be that there is not yet a valid device mode set for the driver or that the “printer driver data” set is still incomplete.

You must make sure that a valid device mode is set for the driver. We now explain what that means.

Setting Device Modes on New Printers

For a printer to be truly usable by a Windows NT/200x/XP client, it must possess:

  • A valid device mode generated by the driver for the printer (defining things like paper size, orientation and duplex settings).

  • A complete set of printer driver data generated by the driver.

If either of these is incomplete, the clients can produce less than optimal output at best. In the worst cases, unreadable garbage or nothing at all comes from the printer, or it produces a harvest of error messages when attempting to print. Samba stores the named values and all printing-related information in its internal TDB database files (ntprinters.tdb, ntdrivers.tdb, printing.tdb, and ntforms.tdb).

The device mode and the set of printer driver data are basically collections of settings for all print queue properties, initialized in a sensible way. Device modes and printer driver data should initially be set on the print server (the Samba host) to healthy values so the clients can start to use them immediately. How do we set these initial healthy values? This can be achieved by accessing the drivers remotely from an NT (or 200x/XP) client, as discussed in the following paragraphs.

Be aware that a valid device mode can only be initiated by a printer admin or root (the reason should be obvious). Device modes can be correctly set only by executing the printer driver program itself. Since Samba cannot execute this Win32 platform driver code, it sets this field initially to NULL (which is not a valid setting for clients to use). Fortunately, most drivers automatically generate the printer driver data that is needed when they are uploaded to the [print$] share with the help of the APW or rpcclient.

The generation and setting of a first valid device mode, however, requires some tickling from a client to set it on the Samba server. The easiest means of doing so is to simply change the page orientation on the server's printer. This executes enough of the printer driver program on the client for the desired effect to happen and feeds back the new device mode to our Samba server. You can use the native Windows NT/200x/XP printer properties page from a Window client for this:

Procedure 21.1. Procedure to Initialize the Printer Driver Settings

  1. Browse the Network Neighborhood.

  2. Find the Samba server.

  3. Open the Samba server's Printers and Faxes folder.

  4. Highlight the shared printer in question.

  5. Right-click on the printer (you may already be here if you followed the last section's description).

  6. At the bottom of the context menu select Properties (if the menu still offers the Connect entry further above, you need to click on that one first to achieve the driver installation, as shown in the last section).

  7. Go to the Advanced tab; click on Printing Defaults.

  8. Change the Portrait page setting to Landscape (and back).

  9. Make sure to apply changes between swapping the page orientation to cause the change to actually take effect.

  10. While you are at it, you may also want to set the desired printing defaults here, which then apply to all future client driver installations.

This procedure executes the printer driver program on the client platform and feeds back the correct device mode to Samba, which now stores it in its TDB files. Once the driver is installed on the client, you can follow the analogous steps by accessing the local Printers folder, too, if you are a Samba printer admin user. From now on, printing should work as expected.

Samba includes a service-level parameter name default devmode for generating a default device mode for a printer. Some drivers function well with Samba's default set of properties. Others may crash the client's spooler service. So use this parameter with caution. It is always better to have the client generate a valid device mode for the printer and store it on the server for you.

Additional Client Driver Installation

Every additional driver may be installed in the same way as just described. Browse Network Neighborhood, open the Printers folder on Samba server, right-click on Printer, and choose Connect.... Once this completes (should be not more than a few seconds, but could also take a minute, depending on network conditions), you should find the new printer in your client workstation local Printers and Faxes folder.

You can also open your local Printers and Faxes folder by using this command on Windows 200x/XP Professional workstations:

rundll32 shell32.dll,SHHelpShortcuts_RunDLL PrintersFolder

or this command on Windows NT 4.0 workstations: