If you're running a SAMBA domain server, you may want to share your network printers out to both your Linux workstations using CUPS and to your Windows workstations using SAMBA. Nobody likes having to run around to all the workstations, download drivers and install the new printer. It's much easier if the SAMBA server will automatically push the drivers out to Windows computers.
The setup for printer sharing is pretty easy, but it can be a headache to have the SAMBA server push out the Windows drivers needed for the Windows desktops to make installation simple.
I'm going to assume you have both CUPS and SAMBA already working, and you're just trying to solve the problem of pushing Windows printer drivers out.
Make sure your /etc/samba/smb.conf file has a [print$] section that looks something like this:
[print$] comment = Printer Drivers path = /var/lib/samba/printers browseable = yes read only = yes guest ok = yes use client driver = yes # you can modify the next two lines to match your needed permissions valid users = "@Domain Users" write list = "@Domain Admins"
At the end of your /etc/cupsd.conf file, add the following lines:
mime.convs: application/octet-stream application/vnd.cups-raw 0 - mime.types: application/octet-stream
Download and install the CUPS Windows driver set from their website. It will be named something like:
cups-windows-6.0-source.tar.gz.
Unzip and install:
sudo apt-get install libcups2-dev tar -zxvf cups-windows-6.0-source.tar.gz cd cups-windows* sudo make install
Now you need a copy of the Windows postscript driver files. I installed a simple HP postscript printer in windows connected to LPT1: (that really didn't exist) to get them. After you've installed a postscript compatible printer in a Windows machine, you should find the files you need somewhere underneath c:\windows\system32\spool\drivers\w32x86\ Mine were in a "\3" subdirectory underneath that. Look for the following files:
ps5ui.dll pscript5.dll pscript.hlp pscript.ntf
Copy those files to the same directory: /usr/share/cups/drivers/, but make sure you change the name of each file to all lowercase.
Your final directory should look something like:
tony@alexandria:/usr/share/cups/drivers# ls -l total 2360 -rw-r--r-- 1 root root 803 2009-03-15 15:52 cups6.inf -rw-r--r-- 1 root root 72 2009-03-15 15:52 cups6.ini -rw-r--r-- 1 root root 12568 2009-03-15 15:52 cupsps6.dll -rw-r--r-- 1 root root 13672 2009-03-15 15:52 cupsui6.dll -rw-r--r-- 1 root root 728576 2009-03-15 16:10 ps5ui.dll -rw-r--r-- 1 root root 543232 2009-03-15 16:01 pscript5.dll -rw-r--r-- 1 root root 26038 2009-03-15 16:01 pscript.hlp -rw-r--r-- 1 root root 1060548 2009-03-15 16:01 pscript.ntf tony@alexandria:/usr/share/cups/drivers#
Now we need to make sure that the appropriate users have rights to add printer drivers. We already set the SAMBA share as the "Domain Admins" group for write, but we need to change ownership of the share directory in Linux to be sure that the Linux permissions don't conflict. The following will change ownership to root with the "Domain Admins" group, and give the group write ability:
sudo chown -R root:"Domain Admins" /var/lib/samba/printers/* sudo chmod -R g+w /var/lib/samba/printers/*
Last, use cupsaddsmb to add the drivers to each available shared printer:
cupsaddsmb -H localhost -U tony -a -v
Obviously, replace "tony" with a user in the "Domain Admins" group specified in the permissions above.
If all goes well (it did for me anyway) you should be able to right click on a printer in Windows and click "Connect" without having to manually install any drivers on the Windows desktop.

Thank you.
This guide helped.
The cupsaddsmb kept failing, and I could't make out why.
the chown/chmod lines were what I was missing.
Thank you a lot.
Ubuntu tip
This was very helpful, but I had no end of troubles with the final step on Ubuntu. Read on for the process I went through and the solution I eventaully found.
Partly I was confused by the "@Domain Users" and "@Domain Admins" part of the Samba config, because I don't have either of those groups. I set them both to my user name, and modified the chown and chmod commands to use my user/group. When I ran the cupsaddsmb command, it kept saying:
SetPrinter call failed!
result was WERR_ACCESS_DENIED
I found another thing saying I needed to grant my user RPC client privileges with this command:
net -U root -S localhost rpc rights grant john SePrintOperatorPrivilege
That's a problem, because Ubuntu doesn't have a root user by default. I tried the command without the -U root and using sudo, but it didn't help.
What eventually worked was this:
1) In smb.conf, I set:
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
browseable = yes
read only = yes
guest ok = yes
admin users = root
write list = root
2) I set the privileges thus:
sudo chown -R root:root /var/lib/samba/printers/*
sudo chmod -R g+w /var/lib/samba/printers/*
3) I used smbpasswd to give "root" an SMB password even though the account doesn't actually exist:
sudo smbpassword -a root
4) I ran the cupsaddsmb command:
cupsaddsmb -H localhost -U root -a -v
And it worked! Voila.
Oh, and I had to remove every occurrence of "use client driver = yes" from my smb.conf.
Thanks for the good write-up, and hope this addendum helps somebody.
Thanks for the comment!
Thanks for the comment! Hopefully someone will find it useful. I run a Samba PDC with LDAP integration and one of the tutorials I followed created the standard Windows domain groups. You'd also find the "@Domain Users", etc. groups if your Samba server is not the primary, but a real Windows server is.
Thanks :)
Great article! I thought my access to print$ was wrong, but doing the chmod/chown thing fixed it. Many thanks.
Cant seem to get it
Cant seem to get it working... I still get asked for windows drivers...
That also happens to me if I
That also happens to me if I don't have permissions to the [printers] (or is it [$printers]) share... I ended up going back and allowing anonymous access to the printers share.
Some quick tips
I just used this guide and have a few "gotchas" that I encountered.
cupsaddsmb uses smbclient, but if smbclient isn't installed, it returns an error that looks like a file permissions or samba config problem. So make sure you have the package installed.
I also had problems performing this as a normal user. I had to add root as a samba user with "smbpasswd -a root", add root to the 'valid users' and 'write list' directives in the smb.conf and then call cupsaddsmb using the root user instead of "Tony".
cupsaddsmb keeps giving me weird errors
like this:
Running command: smbclient //localhost/print$ -N -A /tmp/025c14c4ec035 -c 'mkdir W32X86;put /tmp/025c14c557ff6 W32X86/PDF.ppd;put /usr/share/cups/drivers/ps5ui.dll W32X86/ps5ui.dll;put /usr/share/cups/drivers/pscript.hlp W32X86/pscript.hlp;put /usr/share/cups/drivers/pscript.ntf W32X86/pscript.ntf;put /usr/share/cups/drivers/pscript5.dll W32X86/pscript5.dll'
Domain=[970582] OS=[Unix] Server=[Samba 3.4.7]
NT_STATUS_OBJECT_NAME_COLLISION making remote directory \W32X86
putting file /tmp/025c14c557ff6 as \W32X86/PDF.ppd (11266.1 kb/s) (average 11266.6 kb/s)
putting file /usr/share/cups/drivers/ps5ui.dll as \W32X86/ps5ui.dll (47433.0 kb/s) (average 43178.4 kb/s)
putting file /usr/share/cups/drivers/pscript.hlp as \W32X86/pscript.hlp (8475.6 kb/s) (average 37973.0 kb/s)
putting file /usr/share/cups/drivers/pscript.ntf as \W32X86/pscript.ntf (57538.1 kb/s) (average 47240.9 kb/s)
putting file /usr/share/cups/drivers/pscript5.dll as \W32X86/pscript5.dll (35366.4 kb/s) (average 43880.2 kb/s)
Running command: smbclient //localhost/print$ -N -A /tmp/025c14c4ec035 -c 'put /usr/share/cups/drivers/cups6.ini W32X86/cups6.ini;put /usr/share/cups/drivers/cupsps6.dll W32X86/cupsps6.dll;put /usr/share/cups/drivers/cupsui6.dll W32X86/cupsui6.dll'
Domain=[970582] OS=[Unix] Server=[Samba 3.4.7]
putting file /usr/share/cups/drivers/cups6.ini as \W32X86/cups6.ini (35.2 kb/s) (average 35.2 kb/s)
putting file /usr/share/cups/drivers/cupsps6.dll as \W32X86/cupsps6.dll (12272.2 kb/s) (average 4114.6 kb/s)
putting file /usr/share/cups/drivers/cupsui6.dll as \W32X86/cupsui6.dll (13350.3 kb/s) (average 6423.8 kb/s)
Running command: rpcclient localhost -N -A /tmp/025c14c4ec035 -c 'adddriver "Windows NT x86" "PDF:pscript5.dll:PDF.ppd:ps5ui.dll:pscript.hlp:NULL:RAW:pscript5.dll,PDF.ppd,ps5ui.dll,pscript.hlp,pscript.ntf,cups6.ini,cupsps6.dll,cupsui6.dll"'
Printer Driver PDF successfully installed.
Running command: rpcclient localhost -N -A /tmp/025c14c4ec035 -c 'setdriver PDF PDF'
result was WERR_INVALID_PARAM
Unable to set Windows printer driver (1)!
It repeats this over and over and over again! Any ideas? Why is it trying to install the PDF driver, I haven't shared that printer?
Post new comment