Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

At work my group currently use self maintained network printers. We also run our own self contained Linux network for some members of the group. It all works beautifully. The management has decided that it will be more efficient and sustainable for everybody to use centrally maintained printers. This brings us a number of useful features such as being able to submit a print job and then pick it at any printer we want. The problem is that printing will be tied into the central authentication system, which we don't use.

It turns out that we don't actually have to make use of the authentication as such, we just need to make sure that the username a print job is submitted under has the correct username - otherwise you can't pick it up. We could change all of the username and home directories for all of our users to match the centrally managed ones, but understandably we'd prefer not to do that. If we can remap our usernames to the centrally managed ones for printing then everything should just work.

We're currently using cups for our printing needs and as far as I can tell it doesn't support any form of username remapping. Is this correct? I do know that Samba supports username remapping, but I'm not sure if it would work in this configuration. We need:

  • local username print (to our server if necessary) -> username remapping to central username -> print job sent to print service.

Can anybody suggest how we might achieve this?

share|improve this question
up vote 3 down vote accepted

I have now solved this problem. I've added the real printer as normal, then created a new cups backend script called /usr/lib/cups/backend/remap :


if [ "$#" == "0" ]; then
    echo "network remap \"Unknown\" \"Username remap backend\""
    exit 0

DEVICE_URI=$(echo ${DEVICE_URI} | sed -e "s/^remap/ipp/")
PPD="<path to real printer ppd>"
PRINTER="<real printer name>"
USER=$(ypmatch $2 usermap)
if [ "$?" == "1" ]; then
    exit 1
cat | /usr/lib/cups/backend/ipp ${JOBNUM} ${USER} "${JOBTITLE}" ${COPIES} "$@"
exit $?

I've then added a new fake printer using this backend. The script assumes your fake printer and real printer have the same location but different protocol, so for example:

  • remap://server:631/printers/printer_name
  • ipp://server:631/printers/printer_name

It replaces the "remap" with "http" in the DEVICE_URI environment variable, updates some other environment variables, looks up the mapped user (in this case based on a custom NIS map) and runs the job on the real printer using the ipp backend but with the updated username.

Cups backends expect arguments as follows:

  • $1: CUPS job ID
  • $2: user name
  • $3: job title
  • $4: number of requested copies
  • $5: print job options
  • $6: print job file (with path)

If $6 is empty, it expects input from stdin.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.