Class DirectorySession

java.lang.Object
com.isode.dsapi.DirectorySession
All Implemented Interfaces:
SWIG_DSAPIConstants
Direct Known Subclasses:
IsodeDirectorySession

public class DirectorySession extends Object implements SWIG_DSAPIConstants
Each DirectorySession object represents a connection to a particular directory.

To use a DirectorySession object, callers typically use code of the form:

    DirectorySession sess = new DirectorySession(presaddr);
    .
    .
    sess.bind(bindDN, password, null); // simple bind; no common args
 
that is, specify an address when constructing the object (which will validate the address format), and then attempt to bind as a separate operation.

Note that re-binding is not currently supported; that is, once a successful bind operation has been performed, a subsequent attempt to perform another bind on the same session will result in a NotImplementedException being thrown. This restriction also applies to sessions which have been bound and then unbound.

With some exceptions that are noted in the documentation, DirectorySession objects may be safely shared between multiple threads. So, for example, several separate threads may use the same DirectorySession to perform reads and writes to a given directory. Note that there is no explicit guarantee, in the case of multiple outstanding operations, as to the ordering of operations.

In the case that an application wishes to execute a series of discrete directory operations in a single transaction, without risking another thread performing operations that might invalidate the transaction, callers should synchronize on the DirectorySession object. For example:

   synchronize(session) {
          session.delete(oldDN, null);
          session.rename(newDN, oldDN, null);
   }
 

Obviously, such synchronization cannot protect against problems caused by other directory clients which may be accessing the directory.

Note this class can only be used after a successful call has been made to DSapi.initialize().

See Also: