
For thos of you reading my OS X 10.5 article, Apple made it relatively easy to connect directly to the printer using the add printer functionality when on an active directory system in their newest operating system. However, what are you supposed to do if you are running a PPC that isn't up to par for 10.5? That is the case for a lot of enterprise settings. I found a great article about how to implement log in and log out hooks in 10.4 to allow for network printing without actually joining an Apple to AD.
The steps bellow were tested using a Windows 2003 server box.
--start of file
-- written by Mark Butler, Mark J. Reed, Emmanual, David Thompson and Paul Thompson
-- reads original printers.conf to theText variable
set theText to do shell script ("cat /etc/cups/printers.conf") with administrator privileges
-- set printersconf variable to path to tempfile as string
set printersconf to "/tmp/printers.conf"
set printersconf to (POSIX file printersconf) as string
-- set username and userpass to variables
set username to text returned of (display dialog "Enter your User Name:" default answer "your username")
set userpass to text returned of (display dialog "Enter your Windows password:" default answer "your password" with hidden answer)
-- replace text in variable theText to username and pass
set tempdelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to "username"
set temptext to every text item of theText as list
set AppleScript's text item delimiters to username
set temptext to every item of temptext as string
set AppleScript's text item delimiters to "userpass"
set temptext to every text item of temptext as list
set AppleScript's text item delimiters to userpass
set theText to every item of temptext as string
-- safely convert to unicode special chars
set theText to the theText as Unicode text
-- this is a handler it calls the writefile below with theText variable and printersconf variable
writeFile(theText, printersconf)
-- this creates a backup of the /etc/cups/printer.conf file
do shell script ("cp /etc/cups/printers.conf /etc/cups/ printers.conf.pre-userpass") with administrator privileges
-- this copies the tmp file back to the /etc/cups folder
do shell script ("cp /tmp/printers.conf /etc/cups/printers.conf") with administrator privileges
-- set permissions back on the file
do shell script ("chown root:lp /etc/cups/printers.conf") with administrator privileges
-- restart cups .... not sure you need this but it couldnt hurt
do shell script ("killall -HUP cupsd") with administrator privileges
--- this handler writes the file called earlier these are an easy way to reuse code it can be called multiple times but only needs to be written once...
on writeFile(thecontents, thefile)
set f to (open for access (thefile) with write permission) -- edited
write thecontents to f as string
close access f
end writeFile
--end of file
I saved it as a run only application, and placed it in a folder I created on the local machine in /Library/. I called the folder "Management" but you can call it what you wish. I also created a shell script to reset the printers.conf file on logout, and placed it in the "Management" folder as well. Here is the script:
#start of script
#!/bin/bash
# Simple script to move the printers.conf file back to original status
rm /etc/cups/printers.conf
cp -Rp /etc/cups/printers.conf.pre-userpass /etc/cups/printers.conf
exit
#end of script
The permissions and ownership are set as follows:
chmod 755 /Library/Management **permissions on the management folder**
do a chmod 777 on the files within the management folder
chown -R root:admin /Library/Management
The final part to this puzzle is the creation of Login and Logout hooks in the local machine.
Login Hook ** This is for the AppleScript**
sudo defaults write com.apple.loginwindow LoginHook /Library/ Management/Printing.app
Logout Hook **This is for the shell script**
sudo defaults write com.apple.loginwindow LogoutHook /Library/ Management/Restorecups
The only other thing that needs to be completed is to cd /etc/ cups/ and edit the printers.conf file. Once you set the printers up right once using the Printer Setup Utility, you cd to /etc/cups/ and do a sudo vi printers.conf Replace the username and password that you inputted during the setup and replace it with "username" and "userpass" I have included a sample below for reference:
# Printer configuration file for CUPS v1.1.23
# Written by cupsd on Wed Oct 26 16:33:57 2005
Info Printername
Location Domain
DeviceURI smb://username:pass@Domain/ServerName/Printername
State Idle
Accepting Yes
Shared Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
After checking to make sure it works on one machine, if you have ARD on that machine, you can use it to push all of the information to any other machines that you need to set it up on. You need to push the "Management" folder located in /Library, and the printers.conf file, the PPD folder, and printers.conf.pre-userpass files located in /private/etc/cups/
Thanks so much for the help Paul!
Wednesday, April 16, 2008
AD/ Printing OS X 10.4
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment