Thoughts on NT Printing, Automatic Printer Share Generation

Gerald Carter gcarter at
Wed Oct 25 17:22:37 GMT 2000

I know this is old, but I am just getting around 
to this.  SOrry.

papowell at wrote:
> Ummm...  I suggest you might want to modify PRINTER_DRIVER2.txt:

clarified.  Will check in later.

> <aside>
> Ummm... OK, what are the issues?  I kinda know I 
> don't really want to know,  but I have this 
> masochistic streak that begs to know the worst.
> </aside>


> Downloading drivers works for printers with defined shares,
> but I discovered something REALLY nasty:
>      You have to do this for each individual printer.


> As the author/maintainer of the LPRng print spooler (and 
> a couple of other printing things),  I have a vested 
> interest in making Samba and LPRng interface well.  One 
> of the things that is necessary IMNSHO (In My Not So 
> Humble Opinion) is a way to set up print shares with 
> the MINIMUM of effort by system administrators.

Patrick, you are anything **but** humble :-)

> So I spent a fair time staring/reading/admiring the Samba 
> code that has been added to the SAMBA_2_2 tree - this stuff 
> is VERY clever,  and I congratulate the authors.  Better 
> them than me...  the NT printing stuff looks HORRIBLE!

Tell MS :-)

> c) The existing 'print driver support' requires the 
>    samba administrator to
>     a) find the driver files and download them to 
>        a [PRINTER$] share
>     b) put a line in the 'print driver file' that had 
>        the necessary information to allow W95 systems 
>        to download a driver.  

This step is now unneccessary the Add Printer Wizard
(or Imprints tool) will create the necessray information
and Samba will store both NT and 95 settings in the same
TDB.  One step for NT and 9x (different drivers of course).

>     This resulted in the following smb.conf file:
>         [global]
>           # set defaults
>           printer driver file=/usr/local/samba/lib/printers.def

This goes away.

>           # %h will expand to the Samba Server name
>           printer driver location=\\%h\PRINTER$

This goes away as well.  See the migration section 

> e)  Now,  I just know that you are wondering where this is 
>     going,  and what it has to do with NT printing.  The answer 
>     is quite simple:
>    It is TRIVIAL to add printers with the same drivers to 
>    your system and it does not require administering the 
>    Samba server. You just add them to your printcap:
>      lp1:cm=Apple Printer in Room 1:driver=Apple LaserWriter
>      lp2:cm=Apple Printer in Room 2:driver=Apple LaserWriter

Under the 2.2 system, you simple open the printer properties
and select the driver (if it was already installed for another
printer, then shazamm! you just select it).

We could ( and probably should) code up the necessary 
client side RPC in rpcclient to make this scriptable
from a UNIX shell.

> f) I have looked at the code in SAMBA_2_2,  and it is 
>    really clever the  way that it does printer 
>    driver installation.
>    In order to add the same functionality using the printcap to
>    specify the driver for NT printing,  the following might be
>    done.  (There are alternatives,  and I hope that somebody finds
>    a better one or a better way).
>    1.  When you install an NT printer + Driver,  the driver installation
>       and copy process should generate a 'lookup cookie' that is used to
>       identify the driver for this FAMILY of printers.

The cookie is the NT Driver Name if I understand where 
you are going.

>       I recommend that the cookies start with:
>                W32X86            ; "Windows NT x86"
>                WIN40             ; "Windows 95/98"
>                W32ALPHA          ; "Windows NT Alpha_AXP"
>                W32MIPS           ; "Windows NT R4000"
>                W32PPC            ; "Windows NT PowerPC"
>    2. The 'print driver' field will now be a LIST of strings
>       identifying the driver:
>       printer driver = W32X86_For_NT_cookie,
>           WIN40_For_95_98_cookie,Apple LaserWriter

Don't understand you here.  The 'printer driver' information 
is stored in the printers.tdb  No more smb.conf parameter.

Oh and you only get one driver name associated with a printer.
It is the NT driver name.  (I think we discussed this).
Look in the HKLM\System\CurentControlSet\Services\Print\Drivers\...
and check out the names under different environments.  This
is assuming you have installed a 95 and an NT driver for a 

>    3.  At the start of the driver identification process, 
>        the printer driver string is examined and the appropriate 
>        cookie is located for the appropriate system.  For example,  
>        if the user wants WIN32X86 compatible drivers, you 
>        would look up the cookie using code like the following:
>         char *bingo;
>         if( (bingo = strstr( lp_printerdriver,"WIN32X86")) ){
>                         if( !(end = strchr(bingo,',')) end = bingo + strlen(bingo);
>                         len = end - bingo;
>             copy_substring( cookie, bingo, len );
>             /* now use cookie for your lookup */
>                 }

Problem in that you have locked yourself with a system that 
is incompatible with the APW method.  Any UNIX command line
admin tools should be compatible with the corresponding NT ones
in order to be useful for the entire community.

>     4. Now you use the cookie to look up the driver 
>        information in the database.  Actually, you might 
>        need a 'cookie' to 'really what it wants' lookup table,  
>        but you get the idea.  I hope.

To me, this overly complicates things.  I think JF mentioned this
(I'm having deja Vu I wasting my time on this?  Is it 
old news?  Hmmm...)

For a class of printer sharing a common driver.

for printer in `cat printers`; do

  rpcclient -c 'setprinterdriver $printer DriverName'


In this case, if you have installed an NT and 95 driver 
under the DriverName, then the previous loop gives you both
driver for the new printers at the expense of one call.

>     5. If you do not find the magic cookie, then you use the 
>        code already there -
> f)  There needs to be some way to get the 'cookie' information 
>     for the driver.   One way to do this is to have Samba 
>     maintain/create a file with the cookie information and 
>     printer name.  You also need a way to be able to set up
>     this information.  For example,  if you reinstall samba,  
>     then I gather that all of the data in the TLB disappears.  So 
>     you want to be able to set it up in such a way that the same 
>     cookie references the same information.

If you reinstall your directory server, you still protect 
your backend database right?  same principle here.  Admins
just have to be smart (and yes we need to document this more).

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

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

More information about the samba-technical mailing list