org.springframework.ldap.core.simple

## Interface SimpleLdapOperations

- All Known Implementing Classes:
    SimpleLdapTemplate

  Deprecated.
  Core classes are parameterized as of 2.0.

      public interface SimpleLdapOperations

  LDAP operations interface usable on Java 5 and above, exposing a set of common LDAP operations.
  Author:
    Mattias Hellborg Arthursson

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `authenticate(Name base, String filter, String password)` Deprecated. Utility method to perform a simple LDAP 'bind' authentication.
    `boolean` | `authenticate(String base, String filter, String password)` Deprecated. Utility method to perform a simple LDAP 'bind' authentication.
    `void` | `bind(DirContextOperations ctx)` Deprecated. Bind the data in the supplied context in the tree.
    `void` | `bind(Name dn, Object obj, Attributes attributes)` Deprecated. Create an entry in the LDAP tree.
    `void` | `bind(String dn, Object obj, Attributes attributes)` Deprecated. Create an entry in the LDAP tree.
    `LdapOperations` | `getLdapOperations()` Deprecated. Get the wrapped LdapOperations instance.
    `<T> T` | `lookup(Name dn, ParameterizedContextMapper<T> mapper)` Deprecated. Perform a lookup of the specified DN and map the result using the mapper.
    `<T> T` | `lookup(String dn, ParameterizedContextMapper<T> mapper)` Deprecated. Perform a lookup of the specified DN and map the result using the mapper.
    `DirContextOperations` | `lookupContext(Name dn)` Deprecated. Look up the specified DN, and automatically cast it to a `DirContextOperations` instance.
    `DirContextOperations` | `lookupContext(String dn)` Deprecated. Look up the specified DN, and automatically cast it to a `DirContextOperations` instance.
    `void` | `modifyAttributes(DirContextOperations ctx)` Deprecated. Modify the Attributes of the entry corresponding to the supplied `DirContextOperations` instance.
    `<T> List<T>` | `search(Name base, String filter, ParameterizedContextMapper<T> mapper)` Deprecated. Search for a List of type T using the supplied filter and link ParameterizedContextMapper.
    `<T> List<T>` | `search(Name base, String filter, SearchControls controls, ParameterizedContextMapper<T> mapper, DirContextProcessor processor)` Deprecated. Search for a List of type T using the supplied filter, SearchControls, DirContextProcessor and ParameterizedContextMapper.
    `<T> List<T>` | `search(String base, String filter, ParameterizedContextMapper<T> mapper)` Deprecated. Search for a List of type T using the supplied filter and link ParameterizedContextMapper.
    `<T> List<T>` | `search(String base, String filter, SearchControls controls, ParameterizedContextMapper<T> mapper, DirContextProcessor processor)` Deprecated. Search for a List of type T using the supplied filter, SearchControls, DirContextProcessor and ParameterizedContextMapper.
    `<T> T` | `searchForObject(Name base, String filter, ParameterizedContextMapper<T> mapper)` Deprecated. Perform a search for a unique entry matching the specified search criteria and return the found object.
    `<T> T` | `searchForObject(String base, String filter, ParameterizedContextMapper<T> mapper)` Deprecated. Perform a search for a unique entry matching the specified search criteria and return the found object.
    `void` | `unbind(Name dn)` Deprecated. Remove an entry from the LDAP tree.
    `void` | `unbind(String dn)` Deprecated. Remove an entry from the LDAP tree.

- - ### Method Detail

    - #### getLdapOperations

          LdapOperations getLdapOperations()

      Deprecated.
      Get the wrapped LdapOperations instance.
      Returns:
        the wrapped LdapOperations instance.
      Throws:
        `NamingException` - if any error occurs.

    - #### search

          <T> List<T> search(String base,
                             String filter,
                             ParameterizedContextMapper<T> mapper)

      Deprecated.
      Search for a List of type T using the supplied filter and link ParameterizedContextMapper.
      Parameters:
        `base` - Base DN relative to the base of the ContextSource - where to start the search.
        `filter` - Search filter.
        `mapper` - the Mapper to supply all results to.
      Returns:
        a List of type T containing objects for all entries found, as mapped by the ParameterizedContextMapper.
      Throws:
        `NamingException` - if any error occurs.

    - #### search

          <T> List<T> search(Name base,
                             String filter,
                             ParameterizedContextMapper<T> mapper)

      Deprecated.
      Search for a List of type T using the supplied filter and link ParameterizedContextMapper.
      Parameters:
        `base` - Base DN relative to the base of the ContextSource - where to start the search.
        `filter` - Search filter.
        `mapper` - the Mapper to supply all results to.
      Returns:
        a List of type T containing objects for all entries found, as mapped by the ParameterizedContextMapper.
      Throws:
        `NamingException` - if any error occurs.
      Since:
        1.3

    - #### search

          <T> List<T> search(String base,
                             String filter,
                             SearchControls controls,
                             ParameterizedContextMapper<T> mapper,
                             DirContextProcessor processor)

      Deprecated.
      Search for a List of type T using the supplied filter, SearchControls, DirContextProcessor and ParameterizedContextMapper.
      Parameters:
        `base` - Base DN relative to the base of the ContextSource - where to start the search.
        `filter` - Search filter.
        `controls` - the SearchControls. Make sure that the returningObjFlag is set to `true`.
        `mapper` - the Mapper to supply all results to.
        `processor` - the DirContextProcessor to be used for applying pre/post processing on the DirContext instance.
      Returns:
        a List of type T containing objects for all entries found, as mapped by the ParameterizedContextMapper.
      Throws:
        `NamingException` - if any error occurs.

    - #### search

          <T> List<T> search(Name base,
                             String filter,
                             SearchControls controls,
                             ParameterizedContextMapper<T> mapper,
                             DirContextProcessor processor)

      Deprecated.
      Search for a List of type T using the supplied filter, SearchControls, DirContextProcessor and ParameterizedContextMapper.
      Parameters:
        `base` - Base DN relative to the base of the ContextSource - where to start the search.
        `filter` - Search filter.
        `controls` - the SearchControls. Make sure that the returningObjFlag is set to `true`.
        `mapper` - the Mapper to supply all results to.
        `processor` - the DirContextProcessor to be used for applying pre/post processing on the DirContext instance.
      Returns:
        a List of type T containing objects for all entries found, as mapped by the ParameterizedContextMapper.
      Throws:
        `NamingException` - if any error occurs.
      Since:
        1.3

    - #### lookup

          <T> T lookup(String dn,
                       ParameterizedContextMapper<T> mapper)

      Deprecated.
      Perform a lookup of the specified DN and map the result using the mapper.
      Parameters:
        `dn` - the Distinguished Name to look up.
        `mapper` - the mapper to use.
      Returns:
        the mapped object, as received by the ParameterizedContextMapper.
      Throws:
        `NamingException` - if any error occurs.

    - #### lookup

          <T> T lookup(Name dn,
                       ParameterizedContextMapper<T> mapper)

      Deprecated.
      Perform a lookup of the specified DN and map the result using the mapper.
      Parameters:
        `dn` - the Distinguished Name to look up.
        `mapper` - the mapper to use.
      Returns:
        the mapped object, as received by the ParameterizedContextMapper.
      Throws:
        `NamingException` - if any error occurs.
      Since:
        1.3

    - #### searchForObject

          <T> T searchForObject(String base,
                                String filter,
                                ParameterizedContextMapper<T> mapper)

      Deprecated.
      Perform a search for a unique entry matching the specified search criteria and return the found object. If no entry is found or if there are more than one matching entry, an `IncorrectResultSizeDataAccessException` is thrown.
      Parameters:
        `base` - the DN to use as the base of the search.
        `filter` - the search filter.
        `mapper` - the mapper to use for the search.
      Returns:
        the single object returned by the mapper that matches the search criteria.
      Throws:
        `IncorrectResultSizeDataAccessException` - if the result is not one unique entry
      Since:
        1.3

    - #### searchForObject

          <T> T searchForObject(Name base,
                                String filter,
                                ParameterizedContextMapper<T> mapper)

      Deprecated.
      Perform a search for a unique entry matching the specified search criteria and return the found object. If no entry is found or if there are more than one matching entry, an `IncorrectResultSizeDataAccessException` is thrown.
      Parameters:
        `base` - the DN to use as the base of the search.
        `filter` - the search filter.
        `mapper` - the mapper to use for the search.
      Returns:
        the single object returned by the mapper that matches the search criteria.
      Throws:
        `IncorrectResultSizeDataAccessException` - if the result is not one unique entry
      Since:
        1.3

    - #### lookupContext

          DirContextOperations lookupContext(String dn)

      Deprecated.
      Look up the specified DN, and automatically cast it to a `DirContextOperations` instance.
      Parameters:
        `dn` - The Distinguished Name of the entry to look up.
      Returns:
        A `DirContextOperations` instance constructed from the found entry.
      Throws:
        `NamingException` - if any error occurs.

    - #### lookupContext

          DirContextOperations lookupContext(Name dn)

      Deprecated.
      Look up the specified DN, and automatically cast it to a `DirContextOperations` instance.
      Parameters:
        `dn` - The Distinguished Name of the entry to look up.
      Returns:
        A `DirContextOperations` instance constructed from the found entry.
      Throws:
        `NamingException` - if any error occurs.
      Since:
        1.3

    - #### bind

          void bind(String dn,
                    Object obj,
                    Attributes attributes)

      Deprecated.
      Create an entry in the LDAP tree. The attributes used to create the entry are either retrieved from the `obj` parameter or the `attributes` parameter (or both). One of these parameters may be null but not both.
      Parameters:
        `dn` - The distinguished name to bind the object and attributes to.
        `obj` - The object to bind, may be null. Typically a DirContext implementation.
        `attributes` - The attributes to bind, may be null.
      Throws:
        `NamingException` - if any error occurs.

    - #### bind

          void bind(Name dn,
                    Object obj,
                    Attributes attributes)

      Deprecated.
      Create an entry in the LDAP tree. The attributes used to create the entry are either retrieved from the `obj` parameter or the `attributes` parameter (or both). One of these parameters may be null but not both.
      Parameters:
        `dn` - The distinguished name to bind the object and attributes to.
        `obj` - The object to bind, may be null. Typically a DirContext implementation.
        `attributes` - The attributes to bind, may be null.
      Throws:
        `NamingException` - if any error occurs.
      Since:
        1.3

    - #### bind

          void bind(DirContextOperations ctx)

      Deprecated.
      Bind the data in the supplied context in the tree. All specified Attributes in will be bound to the DN set on the instance.
      Parameters:
        `ctx` - the context to bind
      Throws:
        `IllegalStateException` - if no DN is set or if the instance is in update mode.
      Since:
        1.3

    - #### unbind

          void unbind(String dn)

      Deprecated.
      Remove an entry from the LDAP tree. The entry must not have any children.
      Parameters:
        `dn` - The distinguished name to unbind.
      Throws:
        `NamingException` - if any error occurs.

    - #### unbind

          void unbind(Name dn)

      Deprecated.
      Remove an entry from the LDAP tree. The entry must not have any children.
      Parameters:
        `dn` - The distinguished name to unbind.
      Throws:
        `NamingException` - if any error occurs.
      Since:
        1.3

    - #### modifyAttributes

          void modifyAttributes(DirContextOperations ctx)

      Deprecated.
      Modify the Attributes of the entry corresponding to the supplied `DirContextOperations` instance. The instance should have been received from the `lookupContext(String)` operation, and then modified to match the current state of the matching domain object, e.g.:

           public void update(Person person) {
                  DirContextOperations ctx = simpleLdapOperations.lookup(person.getDn());

                  ctx.setAttributeValue("description", person.getDescription());
                  ctx.setAttributeValue("telephoneNumber", person.getPhone());
                  // More modifications here

                  simpleLdapOperations.modifyAttributes(ctx);
           }

      Parameters:
        `ctx` - the entry to update in the LDAP tree.
      Throws:
        `NamingException` - if any error occurs.

    - #### authenticate

          boolean authenticate(String base,
                               String filter,
                               String password)

      Deprecated.
      Utility method to perform a simple LDAP 'bind' authentication. Search for the LDAP entry to authenticate using the supplied base DN and filter; use the DN of the found entry together with the password as input to `ContextSource.getContext(String, String)`, thus authenticating the entry.

      Example:

           AndFilter filter = new AndFilter();
           filter.and("objectclass", "person").and("uid", userId);
           boolean authenticated = ldapTemplate.authenticate(LdapUtils.emptyLdapName(),
                          filter.toString(), password);

      Parameters:
        `base` - the DN to use as the base of the search.
        `filter` - the search filter - must result in a unique result.
        `password` - the password to use for authentication.
      Returns:
        `true` if the authentication was successful, `false` otherwise.
      Since:
        1.3

    - #### authenticate

          boolean authenticate(Name base,
                               String filter,
                               String password)

      Deprecated.
      Utility method to perform a simple LDAP 'bind' authentication. Search for the LDAP entry to authenticate using the supplied base DN and filter; use the DN of the found entry together with the password as input to `ContextSource.getContext(String, String)`, thus authenticating the entry.

      Example:

           AndFilter filter = new AndFilter();
           filter.and("objectclass", "person").and("uid", userId);
           boolean authenticated = ldapTemplate.authenticate(LdapUtils.emptyLdapName(),
                          filter.toString(), password);

      Parameters:
        `base` - the DN to use as the base of the search.
        `filter` - the search filter - must result in a unique result.
        `password` - the password to use for authentication.
      Returns:
        `true` if the authentication was successful, `false` otherwise.
      Since:
        1.3