Looks basically good to me, though I notice you are using ndbm.
ndbm is known to be evil on many many platforms. You might try
getting gdbm or berkeley db instead. I've seen ndbm fail in
a bunch of nonobvious ways (mostly due to size restrictions).
The other thing you can do is use ldbmtest to take a look at
the database ldif2ldbm created. Looks to me like the lookup of
the base DN you supply in your search "o=The University of Auckland,c=NZ"
is failing. This is contained in the dn2id index file, which
you can look at using ldbmtest. It won't fix the problem, but
you might figure out what the problem is. -- Tim