[Samba] allowing users to install printers

Tomasz Chmielewski mangoo at wpkg.org
Mon Jan 16 12:39:53 GMT 2006


Ian schrieb:
>>>-----BEGIN PGP SIGNED MESSAGE-----
>>>Hash: SHA1
>>>
>>>Tomasz Chmielewski wrote:
>>>
>>>
>>>>>You have to write your own adm file.  You can set any registry
>>>>>setting via an NT4 policy file.
>>>>
>>>>The problem is, I don't really know which registry setting
>>>>I have to set to allow users to set up printers.
>>>
>>>Hence my original suggestion about tweaking it using
>>>gpedit.msc.  Watch what happens (with regmon.exe) when you
>>>change the setting.

Actually, I'm no longer able to add a new printer on a newly installed 
workstation, even with all suggested changes (in gpedit.msc), found in 
google, etc.

Probably I added that printer as an administrator first (and then 
removed it), and then confused it and wrongly assumed that the change in 
gpedit.msc allowed normal users to install printers.

It seems to me that it's impossible to add a printer as a normal user.

So then I banged my head against the wall, because I wasted so much time 
on it, and wrote this little bash script that does everything I wanted.

I'm posting it here in case someone looked for something similar in the 
future.

It produces a batch script which has all the printers installed on a 
Samba server, and adds them on a Windows workstation with "rundll32 
printui.dll,PrintUIEntry ...".

It has to be run as Administrator or SYSTEM first, and then in a 
netlogon script (for a user).
If you're wondering how to execute a batch script as an Administrator or 
SYSTEM, you may check the link at the very bottom of this mail :)


#!/bin/bash

# A script that adds printers for Windows workstations

# Location of the script which adds the printers
# It has to be executed with the permissions of the SYSTEM or
# Administrator first (to add a printer to the workstation)
# and then as a user netlogon script
ADDPRINTERSCRIPT=/home/samba/netlogon/scripts/addprinters.bat

# Find out what printers we have
PRINTERS=`smbclient -L localhost -U% 2>/dev/null|grep Printer| cut -d " 
" -f 1`

# Find out the name of our Samba server
SERVER=`cat /etc/samba/smb.conf | grep "netbios name" | awk '{print $NF}'`

# Clear the script from old printers
 > $ADDPRINTERSCRIPT

# Add new printers
for PRINTER in $PRINTERS

     do

     echo "rundll32 printui.dll,PrintUIEntry /q /y /ga /in /n 
\\\\$SERVER\\$PRINTER" >> $ADDPRINTERSCRIPT

     done

# Convert the script to have dos characters
dos2unix -D $ADDPRINTERSCRIPT

# EOF


-- 
Tomasz Chmielewski
http://wpkg.org


More information about the samba mailing list