Tuesday, July 5, 2011

Configuring a SAMBA Print Server

SkyHi @ Tuesday, July 05, 2011
You may be using Linux at home or in an office environment, but often we still need to provide access to Windows desktops. Begin Linux has taken you though setting up a SAMBA Domain Controller and File Server on openSUSE 11.4. In this tutorial, again using openSUSE 11.4 we will take the time to look at adding in Print Server capabilities. Providing Windows Users have transparent access to printing. The assumption is made that SAMBA is already installed and running on your Linux Server.
We will setup a CUPS (Linux printing) but no great detail of Linux printing is entered into as we are concentrating on SAMBA printing.
For the purpose of this tutorial is not important that your machine is a Domain Controller, although ours will be.


Overview of CUPS printing and creation of a Linux Printer

CUPS, or the Common UNIX Print System, is prevalent in most Linux distributions these days and has been for many years. If we share printers to our network with CUPS then we can print using IPP (Internet Printing Protocol) from our client. As such we should see TCP port 631 open for this purpose if we choose to look with tools such as netstat.
Setting up a CUPS printer could not be easier with openSUSE and YaST especially if, as many homes and businesses do, you have an HP printer model. You can see from the YaST Add Printer Wizard below that there is a “Run hp-setup” tool in the bottom right. This will detect and configure your HP Printer for CUPS printing.

Samba Print Server CUPS

The wizard will start and in this example we select that the printer is on the Network via the Discovery Window. The printer is directly connected to the network.

Samba Print Server Setup
Samba Print Server

The printer is then up and running and available to the Linux Desktop / Server. We can choose to share it via CUPS to our network and print to it from Windows using IPP, this is not the best method as the print driver is not shared, only the printer.
If we share the print driver as well as the printer, users do not need to configure printing and require no additional rights to their machines. For this we require a SAMBA Print Server.
This HP printer will only be shared via SAMBA so we do not need to configure Printer Sharing in YaST. The SAMBA Server prints locally to the CUPS printer so it does not need to be shared by CUPS.
With the wizard complete we now need to look at making this printer and the print driver available to our Windows Users though SAMBA.

Reviewing our Share Definitions to ensure the Linux Printer shares to Windows

The nice feeling that I always have at this point, is in the knowing that the SAMBA defaults to share all printers. We should check this to ensure that we have not missed anything and to complete our understanding of the contents of the /etc/samba/smb.conf file.
Samba Print Server smb.conf
From the extract above we can see:
  1. [printers] share: sharing all our Linux Printers. We can control access to the printers via Access Control List on the printer once configured.
  2. [print$] share: Always present on a Windows Print Server and hosts the print drivers for the clients. The location of this share is shown and we should see the path /var/lib/samba/drivers. You can change the location but there is no real advantage in doing so.
The path shown does exit but only holds a top level structure to represent hardware platforms. It does not contain any drivers. We have to add the Windows drivers to match the OS and Platform of our clients. So if we use 32 bit versions of Windows XP we must add the required drivers for all our printers into the directory: /var/lib/samba/drivers/W32X86. Drivers are easily added using the correct Windows OS and logged in as root. The graphic shows the directory structure (and the empty W32X86 directory) of the print$ share.

Samba Print Server Directory Structure

Windows Printer Drivers and the Print$ share

We will now move away from Linux to manage the print share from a Windows XP client, assuming we wish to add XP drivers. In this way we can add Windows drivers for the shared printer to the print$ share on the server.
We are working in a SAMBA Domain environment which we have already set-up with Begin Linux tutorials. Having created our Domain Administrators group, to ensure correct permissions, we are able to manage printers as the root user. The root user has also been SAMBA enabled. The XP workstation has been added to the BEGINLINUX domain in the normal manner using the System Control Panel. From the graphic below we will log in as root to the XP Workstation having joined the domain and restarted Windows.

Samba Print Server XP Workstation Added

In the setup of the SAMBA domain we have already made sure that root and other administrators have correct rights to manage Domain Machines by nominating a Linux Group to be Windows Domain Administrators.

net groupmap add ntgroup=“Domain Admins” unixgroup=domadmin rid=512 type=d
We can verify that this is set correctly and effective on the XP Workstation by checking the membership of the local administrators group, it should have BeginLinux\Domain Admins in its membership list.

Samba Print Server XP Workstation Added

So now we are in the Domain, (if it is a workgroup then just log on to XP locally and when we connect to the Print Server adding the root username and password then), you will need to connect to the Print Server using its’ name or IP Address. In the example the IP Address of the Server is used. From the start menu on Windows XP choose run and in the dialogue box type \\192.168.0.110 or at least the IP Address or Server Name or your Print Server.

Samba Print Server Administrators

If all is working then we should be displayed a list of shares including the printer share. We do not connect to the printer share but rather to “Printers and Faxes”. This will allow us to manage the Samba Printer instead of just connecting to the printer (HP) in the graphic following.

Samba Print Server Run

From within “Printers and Faxes” right-click on the HP printer and choose “Properties”. A dialogue will warn you that you have not added a driver yet. Select to “Add a Driver Now” and from the Windows selection box choose your printer model, or Have Disk if you need to load a driver that is not available to Windows.
NOTE: Now this is the strange bit, it does not add the driver at this stage. Choose the Advanced Tab and select New Driver. This will add the print driver to the share. I always select an incorrect driver from the first selection then with New Driver I add the correct driver, but we have to do this extra step even though it does not seem to make a lot of sense.

Samba Print Server
If you look at the driver being copied, once the wizard is complete, you will see that this time the driver is copied to the print$ share and the correct subdirectory. See below:

Samba Print Server Copying Files

Finally let’s look at the share to see what we have added: from the run command, again, select \\192.168.110\print$, (adjusting to your server details). You should see a result similar to this is in the W32X86 directory. Look carefully at the address bar to gauge how it will appear on your system.

Samba Print Server
From this point forward users just need to double-click on the HP printer share to add the driver to their own system without any elevated rights. The driver from the Print Server loads in RAM on the client. For each shared CUPS printer you will need to repeat this procedure. For the home or small office though one or two printers is about what you would expect. But there you have it, you have now set up printing via SAMBA on openSUSE 11.4
If you enjoyed this openSUSE tutorial by Andrew Mallett, please visit the openSUSE tutorial section for a complete list.

REFERENCES