Serialization/Serialize/Serializing Java Objects to Directory

Applications and services can use the directory in different ways to store and locate objects:

  • Store (a copy of) the object itself
  • Store a reference to an object
  • Store attributes that describe the object

Programmatically, all applications use one of the following methods when storing objects in the directory:

For storing the below objects types, please refer to the JNDI Tutorial:

Deserialization/Deserialize/Deserializing Java Objects From Directory

Programmatically, all applications use one of the following methods to get a copy of the object back from the directory:

In all of these cases, object factories might be involved

Windows Active Directory

Context.rebind() and DirContext.rebind() do not work against Active Directory because these methods work by reading the attributes of the entry to be updated, removing the entry, and then adding a new entry that contains the modified attributes. Active Directory returns some attributes that cannot be set by the user, causing the final addition step to fail. The workaround for this problem is to use DirContext.getAttributes() to obtain and save the attributes that you want to keep. Then, remove the entry and add it back with the saved attributes (and any others that you want to add) using DirContext.bind().