org.opends.server.admin.client.ldap
Class JNDIDirContextAdaptor

java.lang.Object
  extended by org.opends.server.admin.client.ldap.LDAPConnection
      extended by org.opends.server.admin.client.ldap.JNDIDirContextAdaptor

public final class JNDIDirContextAdaptor
extends LDAPConnection

An LDAP connection adaptor which maps LDAP requests onto an underlying JNDI connection context.


Method Summary
static JNDIDirContextAdaptor adapt(javax.naming.directory.DirContext dirContext)
          Adapts the provided JNDI DirContext.
 void createEntry(javax.naming.ldap.LdapName dn, javax.naming.directory.Attributes attributes)
          Creates a new entry with the specified set of attributes.
 void deleteSubtree(javax.naming.ldap.LdapName dn)
          Deletes the named subtree.
 boolean entryExists(javax.naming.ldap.LdapName dn)
          Determines whether or not the named entry exists.
 java.util.Collection<javax.naming.ldap.LdapName> listEntries(javax.naming.ldap.LdapName dn, java.lang.String filter)
          Lists the children of the named entry.
 void modifyEntry(javax.naming.ldap.LdapName dn, javax.naming.directory.Attributes mods)
          Modifies the attributes of the named entry.
 javax.naming.directory.Attributes readEntry(javax.naming.ldap.LdapName dn, java.util.Collection<java.lang.String> attrIds)
          Reads the attributes of the named entry.
static JNDIDirContextAdaptor simpleBind(java.lang.String host, int port, java.lang.String name, java.lang.String password)
          Creates a new JNDI connection adaptor by performing a simple bind operation to the specified LDAP server.
 void unbind()
          Closes the LDAP connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

adapt

public static JNDIDirContextAdaptor adapt(javax.naming.directory.DirContext dirContext)
Adapts the provided JNDI DirContext.

Parameters:
dirContext - The JNDI connection.
Returns:
Returns a new JNDI connection adaptor.

simpleBind

public static JNDIDirContextAdaptor simpleBind(java.lang.String host,
                                               int port,
                                               java.lang.String name,
                                               java.lang.String password)
                                        throws CommunicationException,
                                               AuthenticationNotSupportedException,
                                               AuthenticationException
Creates a new JNDI connection adaptor by performing a simple bind operation to the specified LDAP server.

Parameters:
host - The host.
port - The port.
name - The LDAP bind DN.
password - The LDAP bind password.
Returns:
Returns a new JNDI connection adaptor.
Throws:
CommunicationException - If the client cannot contact the server due to an underlying communication problem.
AuthenticationNotSupportedException - If the server does not support simple authentication.
AuthenticationException - If authentication failed for some reason, usually due to invalid credentials.

createEntry

public void createEntry(javax.naming.ldap.LdapName dn,
                        javax.naming.directory.Attributes attributes)
                 throws javax.naming.NamingException
Creates a new entry with the specified set of attributes.

Specified by:
createEntry in class LDAPConnection
Parameters:
dn - The name of the entry to be created.
attributes - The set of attributes.
Throws:
javax.naming.NamingException - If an error occurred whilst creating the entry.

deleteSubtree

public void deleteSubtree(javax.naming.ldap.LdapName dn)
                   throws javax.naming.NamingException
Deletes the named subtree.

Specified by:
deleteSubtree in class LDAPConnection
Parameters:
dn - The name of the subtree to be deleted.
Throws:
javax.naming.NamingException - If an error occurred whilst deleting the subtree.

entryExists

public boolean entryExists(javax.naming.ldap.LdapName dn)
                    throws javax.naming.NamingException
Determines whether or not the named entry exists.

Specified by:
entryExists in class LDAPConnection
Parameters:
dn - The name of the entry.
Returns:
Returns true if the entry exists.
Throws:
javax.naming.NamingException - If an error occurred whilst making the determination.

listEntries

public java.util.Collection<javax.naming.ldap.LdapName> listEntries(javax.naming.ldap.LdapName dn,
                                                                    java.lang.String filter)
                                                             throws javax.naming.NamingException
Lists the children of the named entry.

Specified by:
listEntries in class LDAPConnection
Parameters:
dn - The name of the entry to list.
filter - An LDAP filter string, or null indicating the default filter of (objectclass=*).
Returns:
Returns the names of the children.
Throws:
javax.naming.NamingException - If an error occurred whilst listing the children.

modifyEntry

public void modifyEntry(javax.naming.ldap.LdapName dn,
                        javax.naming.directory.Attributes mods)
                 throws javax.naming.NamingException
Modifies the attributes of the named entry.

Specified by:
modifyEntry in class LDAPConnection
Parameters:
dn - The name of the entry to be modified.
mods - The list of attributes which need replacing.
Throws:
javax.naming.NamingException - If an error occurred whilst applying the modifications.

readEntry

public javax.naming.directory.Attributes readEntry(javax.naming.ldap.LdapName dn,
                                                   java.util.Collection<java.lang.String> attrIds)
                                            throws javax.naming.NamingException
Reads the attributes of the named entry.

Specified by:
readEntry in class LDAPConnection
Parameters:
dn - The name of the entry to be read.
attrIds - The list of attributes to be retrievd.
Returns:
Returns the attributes of the requested entry.
Throws:
javax.naming.NamingException - If an error occurred whilst reading the entry.

unbind

public void unbind()
Closes the LDAP connection.

Specified by:
unbind in class LDAPConnection