Novell Home

iPrint via PHP - LDAP

Novell Cool Solutions: Feature
By Daniel Bray

Digg This - Slashdot This

Posted: 25 May 2004
 

summary

We use the following PHP script in our NetWare environment to dynamically list out all of our iPrint printers. iPrint comes with a great visual Map feature, but we've found that this doesn't always prove to be easily manageable in a Hospital environment where things are always getting moved around, devices are always being relocated, and even walls are moved. Plant Ops doesn't always keep the most up to date drawings of all of our buildings, so I've found the following to work nicely. It uses LDAP to dynamically list out the printers, and PHP to parse through the information and present it in a VERY easy to use manner. The speed of the NetWare LDAP system is quite amazing, add that to the power of PHP and you'll be able to do some very cool things. Check it out, and if you still have questions feel free to contact me.

prerequisites
  • Novell's iPrint server configured and installed, running Apache and PHP


  • An understanding of LDAP (terms like basedn, ou...etc.)


  • A NetWare server preconfigured with LDAP services


  • iPrint printers setup in a specific OU structure. (explained below)


  • An "iPrint_Admin" user (or whatever you want to call it) with read rights to the iPrint OU (see below)
procedure

1. Setup iPrint printers in a specific OU

This might be one of the more difficult parts for some individuals, since it might involve changing your NDS tree around from its current structure. However, if you are just starting out with iPrint, or you only have a few printers already created, then it will be easy to just move things into place.

We started out with iPrint printers all over the tree, and found that moving them into this three-tier structure was not that hard, and the end results were more organized and easier to manage. The important part is to understand that the OU structure has to be limited to a three-tier level. Something like this:

....or here's an actual print screen of our NDS tree:

As you can see, it makes sense. You start with the iPrint OU (our basedn) and put the "iPrint_Admin" user object with read rights in the root of this OU, then from there you create a "Building" OU, within that a "Floor" OU and then a "Location" OU. For multiple buildings, floors or locations, just repeat the process, keeping in mind that the limit is three-tier. Meaning, don't create another OU within the "Location" OU. If the building doesn't have multiple floors or locations, then that is fine. You can place the printers anywhere within the Building OU, and the script will list them out. (Don't worry, it will all make sense once you see it running.)

2. The PHP script

Well, since it would look too cluttered for me to cut and paste the actual script in this page, I'll just give you a link to download the script and other stuff:

Download it from here

When extracted, you should have an iPrint folder, and within that folder is an index.php file. Open that up in a text editor (or whatever) and change some of the variables at the top to reflect your LDAP information:

$host="ldapserver.company.com"; 
   //change this to your ldap server
$basedn = "ou=iPrint,o=organization";   
   //change this to your basedn
$auth_user="cn=iPrint_Admin,ou=iPrint,o=organization";   
   //change this to your ldap user
$auth_password="i.love.OpenSource";    
   //change this to your ldap user's password

Once you have the structure from Step 1 created, and have changed the information from above, you should be able to put that iPrint folder in a web directory and launch it.

Some of you might be able to tell, I simply grabbed some of the graphics that came with the iPrint setup, and made this look very similar to a standard Novell web application. Here is a print screen with the page in action.


Click image for larger view.

That page listed a little over 50 printers, and it did that in about 1 second!!! No, I'm not kidding....that's how fast Novell LDAP is....not bad...huh? In fact, when I started all of this, to test out the speed of LDAP, I wrote up a little Perl script that would generate LDAP objects with the proper attributes. Well, unfortunately, I missed one little mundane detail...I put in an extra zero and accidently created 5,000 printer objects instead of 500. :-) It was still extremely quick, listing out all the printers in a matter of seconds!

Each printer that is clickable (in blue), will bring you to one of two things:

  • If you do not have that specific printer installed, it will install the printer via iPrint just as it would if you had clicked on it from the map page.
  • If you already have that printer installed, then you will just go to that printer's iPrint web page.

  • The PHP script parses through each LDAP object looking for a specific attribute: ndpsprinterxri. Once it finds that, with a little PHP code, it turns it into a URL. If you know how to write PHP code, look over the script, and I'm sure you'll see how easy it is and you might even see some improvements for your specific environment. In fact, I plan on adding this to Novell Forge for an open source project so others out there can improve this method.

    We use ZENworks to distribute out the iPrint client, and then just launch a web browser with the iPrint web page as a command line parameter. The users are presented with the above menu system, and after a couple of choices, they are presented with their available printers.

    conclusion

    We have been using this method in our environment for over a year now, and it has worked like a charm. Even on some of our locations where we have over 100 printers in a building, it lists them all in only a couple of seconds. The PHP script probably could be improved, but it does work, so use it however you like. If you make changes, let me know as I am always looking for ways to improve it. Or, if you can't seem to get something to work contact me, and I'll try to help out.

    Happy printing!


    Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

    © 2014 Novell