org.springframework.ldap.core

## Class DirContextAdapter

- java.lang.Object
- - org.springframework.ldap.core.DirContextAdapter

- All Implemented Interfaces:
    Context, DirContext, AttributeModificationsAware, DirContextOperations, LdapDataEntry

      public class DirContextAdapter
      extends Object
      implements DirContextOperations

  Adapter that implements the interesting methods of the DirContext interface. In particular it contains utility methods for getting and setting attributes. Using the `DefaultDirObjectFactory` in your `ContextSource` (which is the default) you will receive instances of this class from searches and lookups. This can be particularly useful when updating data, since this class implements `AttributeModificationsAware`, providing a `getModificationItems()` method. When in update mode, an object of this class keeps track of the changes made to its attributes, making them available as an array of `ModificationItem` objects, suitable as input to `LdapTemplate.modifyAttributes(DirContextOperations)`.

  This class is aware of the specifics of `Name` instances with regards to equality when working with attribute values. This comes in very handy when working with e.g. security groups and modifications of them. If `Name` instances are supplied to one of the Attribute manipulation methods (e.g. `addAttributeValue(String, Object)`, `removeAttributeValue(String, Object)`, `setAttributeValue(String, Object)`, or `setAttributeValues(String, Object[])`), the produced modifications will be calculated using `Name` equality. This means that if an the `member` has a value of `"cn=John Doe,ou=People"`, and we call `addAttributeValue("member", LdapUtils.newLdapName("CN=John Doe,OU=People")`, this will not be considered a modification since the two DN strings represent the same distinguished name (case and spacing between attributes is disregarded).

  Note that this is not a complete implementation of DirContext. Several methods are not relevant for the intended usage of this class, so they throw UnsupportOperationException.

  Author:
    Magnus Robertsson, Andreas Ronge, Adam Skogman, Mattias Hellborg Arthursson
  See Also:
    `setAttributeValue(String, Object)`, `setAttributeValues(String, Object[])`, `getStringAttribute(String)`, `getStringAttributes(String)`, `getObjectAttribute(String)`, `addAttributeValue(String, Object)`, `removeAttributeValue(String, Object)`, `setUpdateMode(boolean)`, `isUpdateMode()`

- - ### Field Summary

    - ### Fields inherited from interface javax.naming.directory.DirContext

      `ADD_ATTRIBUTE, REMOVE_ATTRIBUTE, REPLACE_ATTRIBUTE`

    - ### Fields inherited from interface javax.naming.Context

      `APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `DirContextAdapter()` Default constructor.
    `` | `DirContextAdapter(Attributes attrs, Name dn)` Create a new adapter from the supplied attributes and dn.
    `` | `DirContextAdapter(Attributes attrs, Name dn, Name base)` Create a new adapter from the supplied attributes, dn, and base.
    `` | `DirContextAdapter(Attributes attrs, Name dn, Name base, String referralUrl)` Create a new adapter from the supplied attributes, dn, base, and referral url.
    `protected` | `DirContextAdapter(DirContextAdapter main)` Constructor for cloning an existing adapter.
    `` | `DirContextAdapter(Name dn)` Create a new adapter from the supplied dn.
    `` | `DirContextAdapter(String dnString)` Create a new DirContextAdapter from the supplied DN String.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAttributeValue(String name, Object value)` Add a value to the Attribute with the specified name.
    `void` | `addAttributeValue(String name, Object value, boolean addIfDuplicateExists)` Add a value to the Attribute with the specified name.
    `Object` | `addToEnvironment(String propName, Object propVal)`
    `boolean` | `attributeExists(String name)` Check if an Object attribute exists, regardless of whether it has a value or not.
    `void` | `bind(Name name, Object obj)`
    `void` | `bind(Name name, Object obj, Attributes attrs)`
    `void` | `bind(String name, Object obj)`
    `void` | `bind(String name, Object obj, Attributes attrs)`
    `void` | `close()`
    `Name` | `composeName(Name name, Name prefix)`
    `String` | `composeName(String name, String prefix)`
    `Context` | `createSubcontext(Name name)`
    `DirContext` | `createSubcontext(Name name, Attributes attrs)`
    `Context` | `createSubcontext(String name)`
    `DirContext` | `createSubcontext(String name, Attributes attrs)`
    `void` | `destroySubcontext(Name name)`
    `void` | `destroySubcontext(String name)`
    `boolean` | `equals(Object o)`
    `protected boolean` | `exists(Attribute attr)` Checks if an entry has a specific attribute.
    `protected boolean` | `exists(String attrId)` Checks if the attribute exists in this entry, either it was read or it has been added and update() has been called.
    `Attributes` | `getAttributes()` Get all attributes.
    `Attributes` | `getAttributes(Name name)`
    `Attributes` | `getAttributes(Name name, String[] attrIds)`
    `Attributes` | `getAttributes(String name)`
    `Attributes` | `getAttributes(String name, String[] attrIds)`
    `SortedSet<String>` | `getAttributeSortedStringSet(String name)` Get all String values of the attribute as a `SortedSet`.
    `Name` | `getDn()` Returns the DN relative to the base path.
    `Hashtable<?,?>` | `getEnvironment()`
    `ModificationItem[]` | `getModificationItems()` Creates an array of which attributes have been changed, added or removed since the initialization of this object.
    `String` | `getNameInNamespace()`
    `NameParser` | `getNameParser(Name name)`
    `NameParser` | `getNameParser(String name)`
    `String[]` | `getNamesOfModifiedAttributes()` Creates a String array of the names of the attributes which have been changed.
    `Object` | `getObjectAttribute(String name)` Get the value of an Object attribute.
    `Object[]` | `getObjectAttributes(String name)` Get all values of an Object attribute.
    `String` | `getReferralUrl()` If this instance results from a referral, this method returns the url of the referred server.
    `DirContext` | `getSchema(Name name)`
    `DirContext` | `getSchema(String name)`
    `DirContext` | `getSchemaClassDefinition(Name name)`
    `DirContext` | `getSchemaClassDefinition(String name)`
    `String` | `getStringAttribute(String name)` Get the value of a String attribute.
    `String[]` | `getStringAttributes(String name)` Get all values of a String attribute.
    `int` | `hashCode()`
    `boolean` | `isReferral()` Checks whether this instance results from a referral.
    `boolean` | `isUpdateMode()` Gets the update mode.
    `NamingEnumeration<NameClassPair>` | `list(Name name)`
    `NamingEnumeration<NameClassPair>` | `list(String name)`
    `NamingEnumeration<Binding>` | `listBindings(Name name)`
    `NamingEnumeration<Binding>` | `listBindings(String name)`
    `Object` | `lookup(Name name)`
    `Object` | `lookup(String name)`
    `Object` | `lookupLink(Name name)`
    `Object` | `lookupLink(String name)`
    `void` | `modifyAttributes(Name name, int modOp, Attributes attrs)`
    `void` | `modifyAttributes(Name name, ModificationItem[] mods)`
    `void` | `modifyAttributes(String name, int modOp, Attributes attrs)`
    `void` | `modifyAttributes(String name, ModificationItem[] mods)`
    `void` | `rebind(Name name, Object obj)`
    `void` | `rebind(Name name, Object obj, Attributes attrs)`
    `void` | `rebind(String name, Object obj)`
    `void` | `rebind(String name, Object obj, Attributes attrs)`
    `void` | `removeAttributeValue(String name, Object value)` Remove a value from the Attribute with the specified name.
    `Object` | `removeFromEnvironment(String propName)`
    `void` | `rename(Name oldName, Name newName)`
    `void` | `rename(String oldName, String newName)`
    `NamingEnumeration<SearchResult>` | `search(Name name, Attributes matchingAttributes)`
    `NamingEnumeration<SearchResult>` | `search(Name name, Attributes matchingAttributes, String[] attributesToReturn)`
    `NamingEnumeration<SearchResult>` | `search(Name name, String filterExpr, Object[] filterArgs, SearchControls cons)`
    `NamingEnumeration<SearchResult>` | `search(Name name, String filter, SearchControls cons)`
    `NamingEnumeration<SearchResult>` | `search(String name, Attributes matchingAttributes)`
    `NamingEnumeration<SearchResult>` | `search(String name, Attributes matchingAttributes, String[] attributesToReturn)`
    `NamingEnumeration<SearchResult>` | `search(String name, String filterExpr, Object[] filterArgs, SearchControls cons)`
    `NamingEnumeration<SearchResult>` | `search(String name, String filter, SearchControls cons)`
    `void` | `setAttribute(Attribute attribute)` Set the supplied attribute.
    `void` | `setAttributeValue(String name, Object value)` Set the with the name `name` to the `value`.
    `void` | `setAttributeValues(String name, Object[] values)` Sets a multivalue attribute, disregarding the order of the values.
    `void` | `setAttributeValues(String name, Object[] values, boolean orderMatters)` Sets a multivalue attribute.
    `void` | `setDn(Name dn)` Set the dn of this entry.
    `void` | `setUpdateMode(boolean mode)` Sets the update mode.
    `String` | `toString()`
    `void` | `unbind(Name name)`
    `void` | `unbind(String name)`
    `void` | `update()` Update the attributes.This will mean that the getters ( `getStringAttribute` methods) will return the updated values, and the modifications will be forgotten (i.e.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### DirContextAdapter

          public DirContextAdapter()

      Default constructor.

    - #### DirContextAdapter

          public DirContextAdapter(String dnString)

      Create a new DirContextAdapter from the supplied DN String.
      Parameters:
        `dnString` - the DN string. Must be syntactically correct, or an exception will be thrown.

    - #### DirContextAdapter

          public DirContextAdapter(Name dn)

      Create a new adapter from the supplied dn.
      Parameters:
        `dn` - the dn.

    - #### DirContextAdapter

          public DirContextAdapter(Attributes attrs,
                                   Name dn)

      Create a new adapter from the supplied attributes and dn.
      Parameters:
        `attrs` - the attributes.
        `dn` - the dn.

    - #### DirContextAdapter

          public DirContextAdapter(Attributes attrs,
                                   Name dn,
                                   Name base)

      Create a new adapter from the supplied attributes, dn, and base.
      Parameters:
        `attrs` - the attributes.
        `dn` - the dn.
        `base` - the base name.

    - #### DirContextAdapter

          public DirContextAdapter(Attributes attrs,
                                   Name dn,
                                   Name base,
                                   String referralUrl)

      Create a new adapter from the supplied attributes, dn, base, and referral url.
      Parameters:
        `attrs` - the attributes.
        `dn` - the dn.
        `base` - the base.
        `referralUrl` - the referral url (if this instance results from a referral).

    - #### DirContextAdapter

          protected DirContextAdapter(DirContextAdapter main)

      Constructor for cloning an existing adapter.
      Parameters:
        `main` - The adapter to be copied.

  - ### Method Detail

    - #### setUpdateMode

          public void setUpdateMode(boolean mode)

      Sets the update mode. The update mode should be `false` for a new entry and `true` for an existing entry that is being updated.
      Parameters:
        `mode` - Update mode.

    - #### isUpdateMode

          public boolean isUpdateMode()

      Gets the update mode. An entry in update mode will keep track of its modifications so that they can be retrieved using `AttributeModificationsAware.getModificationItems()`. The update mode should be `true` for a new entry and `true` for an existing entry that is being updated.
      Specified by:
        `isUpdateMode` in interface `DirContextOperations`
      Returns:
        update mode.

    - #### getNamesOfModifiedAttributes

          public String[] getNamesOfModifiedAttributes()

      Creates a String array of the names of the attributes which have been changed. If this is a new entry, all set entries will be in the list. If this is an updated entry, only changed and removed entries will be in the array.
      Specified by:
        `getNamesOfModifiedAttributes` in interface `DirContextOperations`
      Returns:
        Array of String

    - #### getModificationItems

          public ModificationItem[] getModificationItems()

      Creates an array of which attributes have been changed, added or removed since the initialization of this object.
      Specified by:
        `getModificationItems` in interface `AttributeModificationsAware`
      Returns:
        an array of modification items.

    - #### exists

          protected final boolean exists(Attribute attr)

      Checks if an entry has a specific attribute. This method simply calls exists(String) with the attribute name.
      Parameters:
        `attr` - the attribute to check.
      Returns:
        true if attribute exists in entry.

    - #### exists

          protected final boolean exists(String attrId)

      Checks if the attribute exists in this entry, either it was read or it has been added and update() has been called.
      Parameters:
        `attrId` - id of the attribute to check.
      Returns:
        true if the attribute exists in the entry.

    - #### getStringAttribute

          public String getStringAttribute(String name)

      Get the value of a String attribute. If more than one attribute value exists for the specified attribute, only the first one will be returned. If an attribute has no value, `null` will be returned.
      Specified by:
        `getStringAttribute` in interface `LdapDataEntry`
      Parameters:
        `name` - name of the attribute.
      Returns:
        the value of the attribute if it exists, or `null` if the attribute doesn't exist or if it exists but with no value.

    - #### getObjectAttribute

          public Object getObjectAttribute(String name)

      Get the value of an Object attribute. If more than one attribute value exists for the specified attribute, only the first one will be returned. If an attribute has no value, `null` will be returned.
      Specified by:
        `getObjectAttribute` in interface `LdapDataEntry`
      Parameters:
        `name` - name of the attribute.
      Returns:
        the attribute value as an object if it exists, or `null` if the attribute doesn't exist or if it exists but with no value.

    - #### attributeExists

          public boolean attributeExists(String name)

      Check if an Object attribute exists, regardless of whether it has a value or not.
      Specified by:
        `attributeExists` in interface `LdapDataEntry`
      Parameters:
        `name` - name of the attribute
      Returns:
        `true` if the attribute exists, `false` otherwise

    - #### setAttributeValue

          public void setAttributeValue(String name,
                                        Object value)

      Set the with the name `name` to the `value`. If the value is a `Name` instance, equality for Distinguished Names will be used for calculating attribute modifications.
      Specified by:
        `setAttributeValue` in interface `LdapDataEntry`
      Parameters:
        `name` - name of the attribute.
        `value` - value to set the attribute to.

    - #### addAttributeValue

          public void addAttributeValue(String name,
                                        Object value)

      Add a value to the Attribute with the specified name. If the Attribute doesn't exist it will be created. This method makes sure that the there will be no duplicates of an added value - it the value exists it will not be added again. If the value is a `Name` instance, equality for Distinguished Names will be used for calculating attribute modifications.
      Specified by:
        `addAttributeValue` in interface `LdapDataEntry`
      Parameters:
        `name` - the name of the Attribute to which the specified value should be added.
        `value` - the Attribute value to add.

    - #### addAttributeValue

          public void addAttributeValue(String name,
                                        Object value,
                                        boolean addIfDuplicateExists)

      Add a value to the Attribute with the specified name. If the Attribute doesn't exist it will be created. The `addIfDuplicateExists` parameter controls the handling of duplicates. It `false`, this method makes sure that the there will be no duplicates of an added value - it the value exists it will not be added again. If the value is a `Name` instance, equality for Distinguished Names will be used for calculating attribute modifications.
      Specified by:
        `addAttributeValue` in interface `LdapDataEntry`
      Parameters:
        `name` - the name of the Attribute to which the specified value should be added.
        `value` - the Attribute value to add.
        `addIfDuplicateExists` - `true` will add the value regardless of whether there is an identical value already, allowing for duplicate attribute values; `false` will not add the value if it already exists.

    - #### removeAttributeValue

          public void removeAttributeValue(String name,
                                           Object value)

      Remove a value from the Attribute with the specified name. If the Attribute doesn't exist, do nothing. If the value is a `Name` instance, equality for Distinguished Names will be used for calculating attribute modifications.
      Specified by:
        `removeAttributeValue` in interface `LdapDataEntry`
      Parameters:
        `name` - the name of the Attribute from which the specified value should be removed.
        `value` - the value to remove.

    - #### setAttributeValues

          public void setAttributeValues(String name,
                                         Object[] values)

      Sets a multivalue attribute, disregarding the order of the values. If value is null or value.length == 0 then the attribute will be removed. If update mode, changes will be made only if the array has more or less objects or if one or more object has changed. Reordering the objects will not cause an update. If the values are `Name` instances, equality for Distinguished Names will be used for calculating attribute modifications.
      Specified by:
        `setAttributeValues` in interface `LdapDataEntry`
      Parameters:
        `name` - The id of the attribute.
        `values` - Attribute values.

    - #### setAttributeValues

          public void setAttributeValues(String name,
                                         Object[] values,
                                         boolean orderMatters)

      Sets a multivalue attribute. If value is null or value.length == 0 then the attribute will be removed. If update mode, changes will be made if the array has more or less objects or if one or more string has changed. Reordering the objects will only cause an update if orderMatters is set to true. If the values are `Name` instances, equality for Distinguished Names will be used for calculating attribute modifications.
      Specified by:
        `setAttributeValues` in interface `LdapDataEntry`
      Parameters:
        `name` - The id of the attribute.
        `values` - Attribute values.
        `orderMatters` - If `true`, it will be changed even if data was just reordered.

    - #### update

          public void update()

      Update the attributes.This will mean that the getters ( `getStringAttribute` methods) will return the updated values, and the modifications will be forgotten (i.e. `AttributeModificationsAware.getModificationItems()` will return an empty array.
      Specified by:
        `update` in interface `DirContextOperations`

    - #### getStringAttributes

          public String[] getStringAttributes(String name)

      Get all values of a String attribute.
      Specified by:
        `getStringAttributes` in interface `LdapDataEntry`
      Parameters:
        `name` - name of the attribute.
      Returns:
        a (possibly empty) array containing all registered values of the attribute as Strings if the attribute is defined or `null` otherwise.

    - #### getObjectAttributes

          public Object[] getObjectAttributes(String name)

      Get all values of an Object attribute.
      Specified by:
        `getObjectAttributes` in interface `LdapDataEntry`
      Parameters:
        `name` - name of the attribute.
      Returns:
        a (possibly empty) array containing all registered values of the attribute if the attribute is defined or `null` otherwise.

    - #### getAttributeSortedStringSet

          public SortedSet<String> getAttributeSortedStringSet(String name)

      Get all String values of the attribute as a `SortedSet`.
      Specified by:
        `getAttributeSortedStringSet` in interface `LdapDataEntry`
      Parameters:
        `name` - name of the attribute.
      Returns:
        a `SortedSet` containing all values of the attribute, or `null` if the attribute does not exist.

    - #### setAttribute

          public void setAttribute(Attribute attribute)

      Set the supplied attribute.
      Parameters:
        `attribute` - the attribute to set.

    - #### getAttributes

          public Attributes getAttributes()

      Get all attributes.
      Specified by:
        `getAttributes` in interface `LdapDataEntry`
      Returns:
        all attributes.

    - #### getAttributes

          public Attributes getAttributes(Name name)
                                   throws NamingException

      Specified by:
        `getAttributes` in interface `DirContext`
      Throws:
        `NamingException`

    - #### getAttributes

          public Attributes getAttributes(String name)
                                   throws NamingException

      Specified by:
        `getAttributes` in interface `DirContext`
      Throws:
        `NamingException`

    - #### getAttributes

          public Attributes getAttributes(Name name,
                                          String[] attrIds)
                                   throws NamingException

      Specified by:
        `getAttributes` in interface `DirContext`
      Throws:
        `NamingException`

    - #### getAttributes

          public Attributes getAttributes(String name,
                                          String[] attrIds)
                                   throws NamingException

      Specified by:
        `getAttributes` in interface `DirContext`
      Throws:
        `NamingException`

    - #### modifyAttributes

          public void modifyAttributes(Name name,
                                       int modOp,
                                       Attributes attrs)
                                throws NamingException

      Specified by:
        `modifyAttributes` in interface `DirContext`
      Throws:
        `NamingException`

    - #### modifyAttributes

          public void modifyAttributes(String name,
                                       int modOp,
                                       Attributes attrs)
                                throws NamingException

      Specified by:
        `modifyAttributes` in interface `DirContext`
      Throws:
        `NamingException`

    - #### modifyAttributes

          public void modifyAttributes(Name name,
                                       ModificationItem[] mods)
                                throws NamingException

      Specified by:
        `modifyAttributes` in interface `DirContext`
      Throws:
        `NamingException`

    - #### modifyAttributes

          public void modifyAttributes(String name,
                                       ModificationItem[] mods)
                                throws NamingException

      Specified by:
        `modifyAttributes` in interface `DirContext`
      Throws:
        `NamingException`

    - #### bind

          public void bind(Name name,
                           Object obj,
                           Attributes attrs)
                    throws NamingException

      Specified by:
        `bind` in interface `DirContext`
      Throws:
        `NamingException`

    - #### bind

          public void bind(String name,
                           Object obj,
                           Attributes attrs)
                    throws NamingException

      Specified by:
        `bind` in interface `DirContext`
      Throws:
        `NamingException`

    - #### rebind

          public void rebind(Name name,
                             Object obj,
                             Attributes attrs)
                      throws NamingException

      Specified by:
        `rebind` in interface `DirContext`
      Throws:
        `NamingException`

    - #### rebind

          public void rebind(String name,
                             Object obj,
                             Attributes attrs)
                      throws NamingException

      Specified by:
        `rebind` in interface `DirContext`
      Throws:
        `NamingException`

    - #### createSubcontext

          public DirContext createSubcontext(Name name,
                                             Attributes attrs)
                                      throws NamingException

      Specified by:
        `createSubcontext` in interface `DirContext`
      Throws:
        `NamingException`

    - #### createSubcontext

          public DirContext createSubcontext(String name,
                                             Attributes attrs)
                                      throws NamingException

      Specified by:
        `createSubcontext` in interface `DirContext`
      Throws:
        `NamingException`

    - #### getSchema

          public DirContext getSchema(Name name)
                               throws NamingException

      Specified by:
        `getSchema` in interface `DirContext`
      Throws:
        `NamingException`

    - #### getSchema

          public DirContext getSchema(String name)
                               throws NamingException

      Specified by:
        `getSchema` in interface `DirContext`
      Throws:
        `NamingException`

    - #### getSchemaClassDefinition

          public DirContext getSchemaClassDefinition(Name name)
                                              throws NamingException

      Specified by:
        `getSchemaClassDefinition` in interface `DirContext`
      Throws:
        `NamingException`

    - #### getSchemaClassDefinition

          public DirContext getSchemaClassDefinition(String name)
                                              throws NamingException

      Specified by:
        `getSchemaClassDefinition` in interface `DirContext`
      Throws:
        `NamingException`

    - #### search

          public NamingEnumeration<SearchResult> search(Name name,
                                                        Attributes matchingAttributes,
                                                        String[] attributesToReturn)
                                                 throws NamingException

      Specified by:
        `search` in interface `DirContext`
      Throws:
        `NamingException`

    - #### search

          public NamingEnumeration<SearchResult> search(String name,
                                                        Attributes matchingAttributes,
                                                        String[] attributesToReturn)
                                                 throws NamingException

      Specified by:
        `search` in interface `DirContext`
      Throws:
        `NamingException`

    - #### search

          public NamingEnumeration<SearchResult> search(Name name,
                                                        Attributes matchingAttributes)
                                                 throws NamingException

      Specified by:
        `search` in interface `DirContext`
      Throws:
        `NamingException`

    - #### search

          public NamingEnumeration<SearchResult> search(String name,
                                                        Attributes matchingAttributes)
                                                 throws NamingException

      Specified by:
        `search` in interface `DirContext`
      Throws:
        `NamingException`

    - #### search

          public NamingEnumeration<SearchResult> search(Name name,
                                                        String filter,
                                                        SearchControls cons)
                                                 throws NamingException

      Specified by:
        `search` in interface `DirContext`
      Throws:
        `NamingException`

    - #### search

          public NamingEnumeration<SearchResult> search(String name,
                                                        String filter,
                                                        SearchControls cons)
                                                 throws NamingException

      Specified by:
        `search` in interface `DirContext`
      Throws:
        `NamingException`

    - #### search

          public NamingEnumeration<SearchResult> search(Name name,
                                                        String filterExpr,
                                                        Object[] filterArgs,
                                                        SearchControls cons)
                                                 throws NamingException

      Specified by:
        `search` in interface `DirContext`
      Throws:
        `NamingException`

    - #### search

          public NamingEnumeration<SearchResult> search(String name,
                                                        String filterExpr,
                                                        Object[] filterArgs,
                                                        SearchControls cons)
                                                 throws NamingException

      Specified by:
        `search` in interface `DirContext`
      Throws:
        `NamingException`

    - #### lookup

          public Object lookup(Name name)
                        throws NamingException

      Specified by:
        `lookup` in interface `Context`
      Throws:
        `NamingException`

    - #### lookup

          public Object lookup(String name)
                        throws NamingException

      Specified by:
        `lookup` in interface `Context`
      Throws:
        `NamingException`

    - #### bind

          public void bind(Name name,
                           Object obj)
                    throws NamingException

      Specified by:
        `bind` in interface `Context`
      Throws:
        `NamingException`

    - #### bind

          public void bind(String name,
                           Object obj)
                    throws NamingException

      Specified by:
        `bind` in interface `Context`
      Throws:
        `NamingException`

    - #### rebind

          public void rebind(Name name,
                             Object obj)
                      throws NamingException

      Specified by:
        `rebind` in interface `Context`
      Throws:
        `NamingException`

    - #### rebind

          public void rebind(String name,
                             Object obj)
                      throws NamingException

      Specified by:
        `rebind` in interface `Context`
      Throws:
        `NamingException`

    - #### unbind

          public void unbind(Name name)
                      throws NamingException

      Specified by:
        `unbind` in interface `Context`
      Throws:
        `NamingException`

    - #### unbind

          public void unbind(String name)
                      throws NamingException

      Specified by:
        `unbind` in interface `Context`
      Throws:
        `NamingException`

    - #### rename

          public void rename(Name oldName,
                             Name newName)
                      throws NamingException

      Specified by:
        `rename` in interface `Context`
      Throws:
        `NamingException`

    - #### rename

          public void rename(String oldName,
                             String newName)
                      throws NamingException

      Specified by:
        `rename` in interface `Context`
      Throws:
        `NamingException`

    - #### list

          public NamingEnumeration<NameClassPair> list(Name name)
                                                throws NamingException

      Specified by:
        `list` in interface `Context`
      Throws:
        `NamingException`

    - #### list

          public NamingEnumeration<NameClassPair> list(String name)
                                                throws NamingException

      Specified by:
        `list` in interface `Context`
      Throws:
        `NamingException`

    - #### listBindings

          public NamingEnumeration<Binding> listBindings(Name name)
                                                  throws NamingException

      Specified by:
        `listBindings` in interface `Context`
      Throws:
        `NamingException`

    - #### listBindings

          public NamingEnumeration<Binding> listBindings(String name)
                                                  throws NamingException

      Specified by:
        `listBindings` in interface `Context`
      Throws:
        `NamingException`

    - #### destroySubcontext

          public void destroySubcontext(Name name)
                                 throws NamingException

      Specified by:
        `destroySubcontext` in interface `Context`
      Throws:
        `NamingException`

    - #### destroySubcontext

          public void destroySubcontext(String name)
                                 throws NamingException

      Specified by:
        `destroySubcontext` in interface `Context`
      Throws:
        `NamingException`

    - #### createSubcontext

          public Context createSubcontext(Name name)
                                   throws NamingException

      Specified by:
        `createSubcontext` in interface `Context`
      Throws:
        `NamingException`

    - #### createSubcontext

          public Context createSubcontext(String name)
                                   throws NamingException

      Specified by:
        `createSubcontext` in interface `Context`
      Throws:
        `NamingException`

    - #### lookupLink

          public Object lookupLink(Name name)
                            throws NamingException

      Specified by:
        `lookupLink` in interface `Context`
      Throws:
        `NamingException`

    - #### lookupLink

          public Object lookupLink(String name)
                            throws NamingException

      Specified by:
        `lookupLink` in interface `Context`
      Throws:
        `NamingException`

    - #### getNameParser

          public NameParser getNameParser(Name name)
                                   throws NamingException

      Specified by:
        `getNameParser` in interface `Context`
      Throws:
        `NamingException`

    - #### getNameParser

          public NameParser getNameParser(String name)
                                   throws NamingException

      Specified by:
        `getNameParser` in interface `Context`
      Throws:
        `NamingException`

    - #### composeName

          public Name composeName(Name name,
                                  Name prefix)
                           throws NamingException

      Specified by:
        `composeName` in interface `Context`
      Throws:
        `NamingException`

    - #### composeName

          public String composeName(String name,
                                    String prefix)
                             throws NamingException

      Specified by:
        `composeName` in interface `Context`
      Throws:
        `NamingException`

    - #### addToEnvironment

          public Object addToEnvironment(String propName,
                                         Object propVal)
                                  throws NamingException

      Specified by:
        `addToEnvironment` in interface `Context`
      Throws:
        `NamingException`

    - #### removeFromEnvironment

          public Object removeFromEnvironment(String propName)
                                       throws NamingException

      Specified by:
        `removeFromEnvironment` in interface `Context`
      Throws:
        `NamingException`

    - #### getEnvironment

          public Hashtable<?,?> getEnvironment()
                                        throws NamingException

      Specified by:
        `getEnvironment` in interface `Context`
      Throws:
        `NamingException`

    - #### close

          public void close()
                     throws NamingException

      Specified by:
        `close` in interface `Context`
      Throws:
        `NamingException`

    - #### getNameInNamespace

          public String getNameInNamespace()

      Specified by:
        `getNameInNamespace` in interface `Context`
      Specified by:
        `getNameInNamespace` in interface `DirContextOperations`

    - #### getDn

          public Name getDn()

      Returns the DN relative to the base path. NB: as of version 2.0 the returned name will be an LdapName instance.
      Specified by:
        `getDn` in interface `LdapDataEntry`
      Returns:
        The distinguished name of the current context.
      See Also:
        `getNameInNamespace()`

    - #### setDn

          public final void setDn(Name dn)

      Set the dn of this entry.
      Specified by:
        `setDn` in interface `DirContextOperations`
      Parameters:
        `dn` - the dn.

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getReferralUrl

          public String getReferralUrl()

      If this instance results from a referral, this method returns the url of the referred server.
      Specified by:
        `getReferralUrl` in interface `DirContextOperations`
      Returns:
        The url of the referred server, e.g. `ldap://localhost:389`, or the empty string if this is not a referral.

    - #### isReferral

          public boolean isReferral()

      Checks whether this instance results from a referral.
      Specified by:
        `isReferral` in interface `DirContextOperations`
      Returns:
        `true` if this instance results from a referral, `false` otherwise.