Objects In LDAP Via Java

I've been working on some code to add various UNIXy stuff to LDAP. JNDI has good support for this but a lot of the example code looks like:

DirContext ctx = new InitialDirContext(env);
// create attribute objects
ctx.bind(name, object, attributes);

Unfortunately, this results in a Java serialized object like the following:

dn: ou=Hosts,dc=otoh,dc=org
objectClass: organizationalUnit
objectClass: javaSerializedObject
objectClass: top
objectClass: javaObject
javaSerializedData:: rO0ABXQAAA==
ou: Hosts
javaClassName: java.lang.String
javaClassNames: java.lang.String
javaClassNames: java.lang.Object
javaClassNames: java.io.Serializable
javaClassNames: java.lang.Comparable
javaClassNames: java.lang.CharSequence

Really, not what I was after.

If you're looking to do something in a tree that already has the base DN, you probably want to consider using something like the following instead:

InitialLdapContext ctx = new InitialLdapContext(env, null);
// create attribute objects
ctx.createSubcontext(dn, attributes);

Which results in the far nicer:

dn: ou=Hosts,dc=otoh,dc=org
objectClass: organizationalUnit
objectClass: top
ou: Hosts