mac :: printing in a windows world

June 3 2007

Unless you use print from your Mac in a Windows environment which has a forced password change policy this post won’t be much interest. Its probably old news for most who do… but if you’re not aware of the lpadmin command and hate every time you have to change your Windows (AD) password this could be seriously useful.

I use my PowerBook in at work, which is a largely Windows based environment. In order to print I need to connect the Mac to one of the Samba (SMB) based printer queues. This can be achieved by using the web based admin tool (http://localhost:631/) and following the convention for creating the device string as follows:

smb://myaccount:mypassword@windowsserver/windowsprinter

So in a environment where:

myaccount = chris
mypassword = goldstar
windowsserver = nz_printer01
windowsprinter = nz_akl_moa

you would use the following string:

smb://chris:goldstar@nz_printer01/nz_akl_moa

Then you need to need to tweak the config to your printer driver and set up all the defaults for that printer. However when the inevitable password change occurs in the Windows environment you have to tweak the device settings in the web based system to take account that your password has changed. But then you have to redo all the associated driver and default settings. Now there is probably a way to avoid this but I’m now aware of it. The web based admin is now become a royal pain for me, due to factors I won’t go into.

I have always known of the command line …err.. commands that lie behind the web based admin. But until now have not had the suitable motivation to dig into their effective use. Typically the solution is simple and only took a ten minute scan of the associated man pages.

So if you already have a SMB printer setup and your password has changed all you need to do is issue the following command within the shell (Terminal):

lpadmin -p yourprintername -v smb://myaccount:mypassword@windowsserver/windowsprinter

So if using the example above the password was changed to lucky and you had named the printer MOA the command would be:

lpadmin -p MOA -v smb://chris:lucky@nz_printer01/nz_akl_moa

If you don’t know what printer names you have installed you can use lpstat -p or simply view them through the Print & Fax in System Preferences.... For a look at adding SMB printers using AppleScript check out the Samba Assistant script over at MacEnterprise.org

Apols for the justification on the lpadmin commands - the command is a one liner and those huge gaps just represent a single space each. Must tweak the css style for code!


Filed under: mac  tech