Novell is now a part of Micro Focus

ZEN and the Art of Base 64

Novell Cool Solutions: Tip

Digg This - Slashdot This

Posted: 1 Dec 2004

Is there a way to manipulate ZEN Workstation Objects with LDAP, in eDirectory 8.7.3? At first glance it may seem unlikely, especially when you encounter unrecognizable data in the LDIF file. For example, when you use ConsoleOne to view the zenimgUploadLocation field of an exported LDIF file, you might see something like this -


when all you really expected was a path, like this:


The problem is that this data is Base64-encoded. But there is a way to unscramble it.


If you use a tool like LDAP Browser (2.8.2, by Jarek Gawor), you can see the same field (where x=specialquote):


The data is stored in a format like this: [1 byte "count"]["count" number of entries][2 byte NULL]. Each entry consists of: [2 byte data "length"][utf16 string of "length" bytes][2 byte data "length"][utf16 string of "length" bytes].

In our example of ZEN imaging data, the first unicode string is the path for the image, and the second is the proxy server used to get the image.

To decode these LDAP attributes (Addons, Base, HistoryAddons2, HistoryBase, UploadLocation, etc.) in Perl, you can use a script like this:

use MIME::Base64;
use Unicode::String qw/utf16/;

@vals = map { utf16 $_ } unpack "C/(n/a n/a)", decode_base64 $data;

... where $data is the stuff from LDAP, and @vals is a list of (path1, server1, path2, server2, ...).

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

© Copyright Micro Focus or one of its affiliates