I stumbled across a good-looking bit of software called PINpoint by TENET that produces a list of users registered on a BlackBerry Enterprise Server (BES) and pushes that to the devices. In effect users then have a company BlackBerry directory from which they can look up email addresses, telephone numbers and even PIN numbers. Since the software is a bit pricey and I’m operating on a shoe-string budget, there was no way I could purchase that for our environment. Instead I attempted and succeeded at producing similar information, admitedly without the elegance of afore mentioned software but also without its price tag.
My version is not half as good looking as the commercial program, but it does the job. Oh, and you do always get what you pay for…
What I Used
Our BES runs atop of Lotus Domino, so in the following I’ll have one or Lotus specific details, but the general principle will probably run on a Microsoft Exchange or Novell Groupwise-based BlackBerry Enterprise Server. All of these use a dedicated SQL server or, in smaller environments, an dedicated MSDE database server, into which the BES writes details concerning the devices configured to use that BES as well as its users.
The code below is not guaranteed to survive future versions of a BES; if RIM changes the database schema, the code will either have to be adapted, rewritten or even scrapped entirely. I developed and tested the code on a version 4.1 BES, but as far as I know, it should also work on a version 4.0, and perhaps even earlier versions. Your mileage may vary, and I have no way of testing that.
I’ve tested the code below on a BES running atop Windows 2003 SP2 with a copy of Active Perl for Windows as well as the DBI and ODBC modules installed. To convert the XML to XSLT, I used the XML C Parser and Toolkit which is also available for Windows, including a download section for binaries.
Getting the Details
The database schema used by the BES is undocumented as far as I can tell, but I knew that the information must be in there somewhere. If you look at the BlackBerry Desktop Manager, you see the details clearly:
After poking around a bit inside the SQL server, or rather the MSDE server on our BES, I found the details I needed. Apart from username, telephone number, email address and PIN (those are the fields I most badly wanted to have), there are all sorts of goodies, such as the BlackBerry device operating system version, the model number, etc. The following Perl program runs on the BES server proper and dumps the information I want into an XML format.
The XML should be rather self-explanatory. There is one user entry per user defined on the BES (by the way: you’ll only get entries for users who have already done an enterprise activation; the reason for this is that the join in the program’s SQL joins with the device table, which in turn is only filled after activation). Each user entry in turn has an element corresponding to the database field I’m interested in. Do note, that the elements only exist if the corresponding database field has a value. If for example one of the BES users hasn’t set her telephone number on the device’s SIM Card settings, the element phone will not exist.
The Perl program userlist.pl shown below runs on Windows and connects via ODBC with the MSDE server. The SELECT statement joins three tables to find all the attributes I want to see.
It ought to be quite easy to modify the program to produce an output format of your preference, such as CSV or even to dump it into a separate database. In a subsequent article, I’ll be using this XML to fill a MySQL database table.
Viewing Results on the Device
Now that we are able to produce XML output with the information we are interested in, we need to get that to the device. I’m going to use XSLT to transform the XML into HTML which can be retrieved via HTTP and viewed on the device. One word about the BlackBerry browser: do ensure that you’ve set it up to correctly use HTML tables and style sheets. My browser settings are
XSLT is a transformation language which can transform XML into a different format. For the task at hand, the target should be HTML. If you put both the userlist.xml and userlist.xsl files in the same location (on your web server or even on your local computer) and open the XML with a Mozilla Firefox browser (others may or may not work), you may be astonished to see that Firefox pulls up the XML, sees that it requires a style sheet and loads and applies the XSL to the XML on the fly. Unfortunately the BlackBerry Browser cannot do that, so we’ll transform the XML on the web server. The style sheet proper is shown below:
Once we have the XML we can apply the style-sheet and transform it to HTML.
The invocation of the xsltproc program is trivial:
What this does is to call the XSLT transformation program which reads the name of the stylesheet to use and applies that to the specified XML input file. The output is written to the file userlist.html.
Note how in the resulting HTML, the links to both the phone number and the PIN use the BlackBerry-specific anchors to enable telephony and PIN recognition on the links This transformation can be done periodically on the server by scheduling it.
How to Push the Directory to the Device?
In a future article I’ll be demonstrating a technology with which to do this.