Class LdapConnectionWrapper

java.lang.Object
org.apache.directory.ldap.client.api.LdapConnectionWrapper
All Implemented Interfaces:
Closeable, AutoCloseable, LdapConnection, Wrapper<LdapConnection>
Direct Known Subclasses:
MonitoringLdapConnection, PooledLdapConnection

public class LdapConnectionWrapper extends Object implements LdapConnection, Wrapper<LdapConnection>
Provides a base implementation of a Wrapper for LdapConnection objects. All methods are passed through to the wrapped LdapConnection.
Author:
Apache Directory Project
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected LdapConnection
    The wrapped connection
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a new LdapConnectionWrapper instance
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    abandon(int messageId)
    Abandons a request submitted to the server for performing a particular operation.
    void
    abandon(org.apache.directory.api.ldap.model.message.AbandonRequest abandonRequest)
    An abandon request essentially with the request message ID of the operation to be canceled and/or potentially some controls and timeout (the controls and timeout are not mandatory).
    void
    add(org.apache.directory.api.ldap.model.entry.Entry entry)
    Add an entry to the server.
    org.apache.directory.api.ldap.model.message.AddResponse
    add(org.apache.directory.api.ldap.model.message.AddRequest addRequest)
    Add an entry present in the AddRequest to the server.
    void
    Anonymous bind on a server.
    void
    Bind on a server, using the LdapConnectionConfig information of this connection.
    void
    bind(String name)
    Unauthenticated authentication bind on a server.
    void
    bind(String name, String credentials)
    Simple bind on a server.
    org.apache.directory.api.ldap.model.message.BindResponse
    bind(org.apache.directory.api.ldap.model.message.BindRequest bindRequest)
    Bind to the server using a bind request object.
    void
    bind(org.apache.directory.api.ldap.model.name.Dn name)
    Unauthenticated authentication bind on a server.
    void
    bind(org.apache.directory.api.ldap.model.name.Dn name, String credentials)
    Simple bind on a server.
    org.apache.directory.api.ldap.model.message.BindResponse
    bind(SaslRequest saslRequest)
    SASL Bind to the server using a SASL request object.
    void
    Disconnect from the remote LDAP server.
    boolean
    compare(String dn, String attributeName, byte[] value)
    Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.
    boolean
    compare(String dn, String attributeName, String value)
    Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.
    boolean
    compare(String dn, String attributeName, org.apache.directory.api.ldap.model.entry.Value value)
    Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.
    org.apache.directory.api.ldap.model.message.CompareResponse
    compare(org.apache.directory.api.ldap.model.message.CompareRequest compareRequest)
    Compares an entry's attribute's value with that of the given value.
    boolean
    compare(org.apache.directory.api.ldap.model.name.Dn dn, String attributeName, byte[] value)
    Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.
    boolean
    compare(org.apache.directory.api.ldap.model.name.Dn dn, String attributeName, String value)
    Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.
    boolean
    compare(org.apache.directory.api.ldap.model.name.Dn dn, String attributeName, org.apache.directory.api.ldap.model.entry.Value value)
    Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.
    boolean
    Connect to the remote LDAP server.
    void
    Deletes the entry with the given distinguished name.
    org.apache.directory.api.ldap.model.message.DeleteResponse
    delete(org.apache.directory.api.ldap.model.message.DeleteRequest deleteRequest)
    Performs a delete operation based on the delete request object.
    void
    delete(org.apache.directory.api.ldap.model.name.Dn dn)
    Deletes the entry with the given distinguished name.
    boolean
    doesFutureExistFor(int messageId)
    Checks if there is a ResponseFuture associated with the given message ID.
    tell if an exception was caught while processing the request or a response.
    boolean
    Tells if an entry exists in the server.
    boolean
    exists(org.apache.directory.api.ldap.model.name.Dn dn)
    Tells if an Entry exists in the server.
    org.apache.directory.api.ldap.model.message.ExtendedResponse
    Sends a extended operation request to the server with the given OID and no value.
    org.apache.directory.api.ldap.model.message.ExtendedResponse
    extended(String oid, byte[] value)
    Sends a extended operation request to the server with the given OID and value.
    org.apache.directory.api.ldap.model.message.ExtendedResponse
    extended(org.apache.directory.api.asn1.util.Oid oid)
    Sends a extended operation request to the server with the given OID and no value.
    org.apache.directory.api.ldap.model.message.ExtendedResponse
    extended(org.apache.directory.api.asn1.util.Oid oid, byte[] value)
    Sends a extended operation request to the server with the given OID and value.
    org.apache.directory.api.ldap.model.message.ExtendedResponse
    extended(org.apache.directory.api.ldap.model.message.ExtendedRequest extendedRequest)
    Performs an extended operation based on the extended request object.
    org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector
    Get the BinaryAttribute dectore instance
    org.apache.directory.api.ldap.codec.api.LdapApiService
    Gets the LDAP CODEC service responsible for encoding and decoding messages.
    org.apache.directory.api.ldap.model.entry.Entry
    Get back the RooDSE from the connected server.
    org.apache.directory.api.ldap.model.entry.Entry
    getRootDse(String... attributes)
    Get back the RooDSE from the connected server.
    org.apache.directory.api.ldap.model.schema.SchemaManager
    Get the SchemaManager instance
    Get the Controls supported by server.
    boolean
    Check if the connection is authenticated.
    boolean
    Check if the connection is established
    boolean
    Checks if a control with the given OID is supported.
    boolean
    isRequestCompleted(int messageId)
    Checks if a request has been completed, or not.
    void
    Loads all the default schemas that are bundled with the API.

    Note: This method enables all schemas prior to loading.
    void
    Loads all the default schemas that are bundled with the API, in a relaxed mode.

    Note: This method enables all schemas prior to loading.
    The relaxed mode will allow inconsistencies in the schema.
    org.apache.directory.api.ldap.model.entry.Entry
    Searches for an entry having the given distinguished name.
    org.apache.directory.api.ldap.model.entry.Entry
    lookup(String dn, String... attributes)
    Searches for an entry having the given distinguished name.
    org.apache.directory.api.ldap.model.entry.Entry
    lookup(String dn, org.apache.directory.api.ldap.model.message.Control[] controls, String... attributes)
    Searches for an entry having the given distinguished name.
    org.apache.directory.api.ldap.model.entry.Entry
    lookup(org.apache.directory.api.ldap.model.name.Dn dn)
    Searches for an entry having the given distinguished name..
    org.apache.directory.api.ldap.model.entry.Entry
    lookup(org.apache.directory.api.ldap.model.name.Dn dn, String... attributes)
    Searches for an entry having the given distinguished name.
    org.apache.directory.api.ldap.model.entry.Entry
    lookup(org.apache.directory.api.ldap.model.name.Dn dn, org.apache.directory.api.ldap.model.message.Control[] controls, String... attributes)
    Searches for an entry having the given distinguished name.
    void
    modify(String dn, org.apache.directory.api.ldap.model.entry.Modification... modifications)
    Applies all the modifications to the entry specified by its distinguished name.
    void
    modify(org.apache.directory.api.ldap.model.entry.Entry entry, org.apache.directory.api.ldap.model.entry.ModificationOperation modOp)
    Modifies all the attributes present in the entry by applying the same operation.
    org.apache.directory.api.ldap.model.message.ModifyResponse
    modify(org.apache.directory.api.ldap.model.message.ModifyRequest modRequest)
    Performs an modify operation based on the modifications present in the modify request.
    void
    modify(org.apache.directory.api.ldap.model.name.Dn dn, org.apache.directory.api.ldap.model.entry.Modification... modifications)
    Applies all the modifications to the entry specified by its distinguished name.
    org.apache.directory.api.ldap.model.message.ModifyDnResponse
    modifyDn(org.apache.directory.api.ldap.model.message.ModifyDnRequest modDnRequest)
    Performs the modifyDn operation based on the given request object.
    void
    move(String entryDn, String newSuperiorDn)
    Moves the given entry distinguished name under the new superior distinguished name.
    void
    move(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Dn newSuperiorDn)
    Moves the given entry distinguished name under the new superior distinguished name.
    void
    moveAndRename(String entryDn, String newDn)
    Moves and renames the given entry distinguished name.
    void
    moveAndRename(String entryDn, String newDn, boolean deleteOldRdn)
    Moves and renames the given entryDn.
    void
    moveAndRename(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Dn newDn)
    Moves and renames the given entryDn.
    void
    moveAndRename(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Dn newDn, boolean deleteOldRdn)
    Moves and renames the given entryDn.
    void
    rename(String entryDn, String newRdn)
    Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name.
    void
    rename(String entryDn, String newRdn, boolean deleteOldRdn)
    Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name if deleteOldRdn is set to true.
    void
    rename(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Rdn newRdn)
    Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name.
    void
    rename(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Rdn newRdn, boolean deleteOldRdn)
    Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name if deleteOldRdn is set to true.
    org.apache.directory.api.ldap.model.cursor.EntryCursor
    search(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes)
    Do a search, on the base object, using the given filter and scope.
    org.apache.directory.api.ldap.model.cursor.SearchCursor
    search(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest)
    Performs search using a search request object.
    org.apache.directory.api.ldap.model.cursor.EntryCursor
    search(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes)
    Do a search, on the base object, using the given filter and scope.
    void
    setBinaryAttributeDetector(org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector binaryAttributeDetecter)
    Sets the object responsible for the detection of binary attributes.
    void
    setSchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager)
    sets a SchemaManager to be used by this connection
    void
    setTimeOut(long timeOut)
    Set the timeout for the responses.
    void
    UnBind from a server.
    Returns the wrapped object.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • connection

      protected LdapConnection connection
      The wrapped connection
  • Constructor Details

    • LdapConnectionWrapper

      protected LdapConnectionWrapper(LdapConnection connection)
      Creates a new LdapConnectionWrapper instance
      Parameters:
      connection - The wrapped connection
  • Method Details

    • wrapped

      public LdapConnection wrapped()
      Returns the wrapped object.
      Specified by:
      wrapped in interface Wrapper<LdapConnection>
      Returns:
      The wrapped object
    • isConnected

      public boolean isConnected()
      Check if the connection is established
      Specified by:
      isConnected in interface LdapConnection
      Returns:
      true if the connection is established
    • isAuthenticated

      public boolean isAuthenticated()
      Check if the connection is authenticated.
      Specified by:
      isAuthenticated in interface LdapConnection
      Returns:
      true if the connection is authenticated
    • connect

      public boolean connect() throws org.apache.directory.api.ldap.model.exception.LdapException
      Connect to the remote LDAP server.
      Specified by:
      connect in interface LdapConnection
      Returns:
      true if the connection is established, false otherwise
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • exceptionCaught

      public Throwable exceptionCaught()
      tell if an exception was caught while processing the request or a response.
      Specified by:
      exceptionCaught in interface LdapConnection
      Returns:
      The exception if there was one thrown while processing a request or a response
    • close

      public void close() throws IOException
      Disconnect from the remote LDAP server.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface LdapConnection
      Throws:
      IOException - if some I/O error occurs
    • add

      public void add(org.apache.directory.api.ldap.model.entry.Entry entry) throws org.apache.directory.api.ldap.model.exception.LdapException
      Add an entry to the server.
      Specified by:
      add in interface LdapConnection
      Parameters:
      entry - The entry to add
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • add

      public org.apache.directory.api.ldap.model.message.AddResponse add(org.apache.directory.api.ldap.model.message.AddRequest addRequest) throws org.apache.directory.api.ldap.model.exception.LdapException
      Add an entry present in the AddRequest to the server.
      Specified by:
      add in interface LdapConnection
      Parameters:
      addRequest - the request object containing an entry and controls (if any)
      Returns:
      the add operation's response
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • abandon

      public void abandon(int messageId)
      Abandons a request submitted to the server for performing a particular operation. The abandonRequest is always non-blocking, because no response is expected
      Specified by:
      abandon in interface LdapConnection
      Parameters:
      messageId - the ID of the request message sent to the server
    • abandon

      public void abandon(org.apache.directory.api.ldap.model.message.AbandonRequest abandonRequest)
      An abandon request essentially with the request message ID of the operation to be canceled and/or potentially some controls and timeout (the controls and timeout are not mandatory). The abandonRequest is always non-blocking, because no response is expected.
      Specified by:
      abandon in interface LdapConnection
      Parameters:
      abandonRequest - the abandon operation's request
    • bind

      public void bind() throws org.apache.directory.api.ldap.model.exception.LdapException
      Bind on a server, using the LdapConnectionConfig information of this connection.
      Specified by:
      bind in interface LdapConnection
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • anonymousBind

      public void anonymousBind() throws org.apache.directory.api.ldap.model.exception.LdapException
      Anonymous bind on a server.
      Specified by:
      anonymousBind in interface LdapConnection
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • bind

      public void bind(String name) throws org.apache.directory.api.ldap.model.exception.LdapException
      Unauthenticated authentication bind on a server.
      Specified by:
      bind in interface LdapConnection
      Parameters:
      name - The name used to authenticate the user. It must be a valid distinguished name.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • bind

      public void bind(String name, String credentials) throws org.apache.directory.api.ldap.model.exception.LdapException
      Simple bind on a server.
      Specified by:
      bind in interface LdapConnection
      Parameters:
      name - The name used to authenticate the user. It must be a valid distinguished name.
      credentials - The password, it can't be null
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • bind

      public void bind(org.apache.directory.api.ldap.model.name.Dn name) throws org.apache.directory.api.ldap.model.exception.LdapException
      Unauthenticated authentication bind on a server.
      Specified by:
      bind in interface LdapConnection
      Parameters:
      name - The name used to authenticate the user.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • bind

      public void bind(org.apache.directory.api.ldap.model.name.Dn name, String credentials) throws org.apache.directory.api.ldap.model.exception.LdapException
      Simple bind on a server.
      Specified by:
      bind in interface LdapConnection
      Parameters:
      name - The name used to authenticate the user.
      credentials - The password, it can't be null
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • bind

      public org.apache.directory.api.ldap.model.message.BindResponse bind(org.apache.directory.api.ldap.model.message.BindRequest bindRequest) throws org.apache.directory.api.ldap.model.exception.LdapException
      Bind to the server using a bind request object.
      Specified by:
      bind in interface LdapConnection
      Parameters:
      bindRequest - The bind request object containing all the needed parameters
      Returns:
      A BindResponse containing the result
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • bind

      public org.apache.directory.api.ldap.model.message.BindResponse bind(SaslRequest saslRequest) throws org.apache.directory.api.ldap.model.exception.LdapException
      SASL Bind to the server using a SASL request object.
      Specified by:
      bind in interface LdapConnection
      Parameters:
      saslRequest - The SASL request object containing all the needed parameters
      Returns:
      A BindResponse containing the result
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • search

      public org.apache.directory.api.ldap.model.cursor.EntryCursor search(org.apache.directory.api.ldap.model.name.Dn baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes) throws org.apache.directory.api.ldap.model.exception.LdapException
      Do a search, on the base object, using the given filter and scope. The SearchRequest parameters default to
      • DerefAlias : ALWAYS
      • SizeLimit : none
      • TimeLimit : none
      • TypesOnly : false
      Specified by:
      search in interface LdapConnection
      Parameters:
      baseDn - The base for the search. It must be a valid distinguished name and can't be emtpy
      filter - The filter to use for this search. It can't be empty
      scope - The search scope : OBJECT, ONELEVEL or SUBTREE
      attributes - The attributes to use for this search
      Returns:
      An EntryCursor on the result.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • search

      public org.apache.directory.api.ldap.model.cursor.EntryCursor search(String baseDn, String filter, org.apache.directory.api.ldap.model.message.SearchScope scope, String... attributes) throws org.apache.directory.api.ldap.model.exception.LdapException
      Do a search, on the base object, using the given filter and scope. The SearchRequest parameters default to
      • DerefAlias : ALWAYS
      • SizeLimit : none
      • TimeLimit : none
      • TypesOnly : false
      Specified by:
      search in interface LdapConnection
      Parameters:
      baseDn - The base for the search. It must be a valid distinguished name, and can't be emtpy
      filter - The filter to use for this search. It can't be empty
      scope - The search scope : OBJECT, ONELEVEL or SUBTREE
      attributes - The attributes to use for this search
      Returns:
      An EntryCursor on the result.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • search

      public org.apache.directory.api.ldap.model.cursor.SearchCursor search(org.apache.directory.api.ldap.model.message.SearchRequest searchRequest) throws org.apache.directory.api.ldap.model.exception.LdapException
      Performs search using a search request object.
      Specified by:
      search in interface LdapConnection
      Parameters:
      searchRequest - The search request object containing all the needed information
      Returns:
      a search cursor on the result.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • unBind

      public void unBind() throws org.apache.directory.api.ldap.model.exception.LdapException
      UnBind from a server. This is a request which expects no response.
      Specified by:
      unBind in interface LdapConnection
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • setTimeOut

      public void setTimeOut(long timeOut)
      Set the timeout for the responses. We won't wait longer than this value.
      Specified by:
      setTimeOut in interface LdapConnection
      Parameters:
      timeOut - The timeout, in milliseconds
    • modify

      public void modify(org.apache.directory.api.ldap.model.name.Dn dn, org.apache.directory.api.ldap.model.entry.Modification... modifications) throws org.apache.directory.api.ldap.model.exception.LdapException
      Applies all the modifications to the entry specified by its distinguished name.
      Specified by:
      modify in interface LdapConnection
      Parameters:
      dn - The entry's distinguished name
      modifications - The list of modifications to be applied
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - in case of modify operation failure or timeout happens
    • modify

      public void modify(String dn, org.apache.directory.api.ldap.model.entry.Modification... modifications) throws org.apache.directory.api.ldap.model.exception.LdapException
      Applies all the modifications to the entry specified by its distinguished name.
      Specified by:
      modify in interface LdapConnection
      Parameters:
      dn - The entry's distinguished name, it must be a valid distinguished name.
      modifications - The list of modifications to be applied
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - in case of modify operation failure or timeout happens
    • modify

      public void modify(org.apache.directory.api.ldap.model.entry.Entry entry, org.apache.directory.api.ldap.model.entry.ModificationOperation modOp) throws org.apache.directory.api.ldap.model.exception.LdapException
      Modifies all the attributes present in the entry by applying the same operation.
      Specified by:
      modify in interface LdapConnection
      Parameters:
      entry - the entry with the attributes to be modified
      modOp - the operation to be applied on all the attributes of the above entry
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - in case of modify operation failure or timeout happens
    • modify

      public org.apache.directory.api.ldap.model.message.ModifyResponse modify(org.apache.directory.api.ldap.model.message.ModifyRequest modRequest) throws org.apache.directory.api.ldap.model.exception.LdapException
      Performs an modify operation based on the modifications present in the modify request.
      Specified by:
      modify in interface LdapConnection
      Parameters:
      modRequest - the modify request object
      Returns:
      the modify operation's response
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - in case of modify operation failure or timeout happens
    • rename

      public void rename(String entryDn, String newRdn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name.
      Specified by:
      rename in interface LdapConnection
      Parameters:
      entryDn - the target distinguished name.
      newRdn - new relative distinguished name for the target distinguished name.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
      See Also:
    • rename

      public void rename(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Rdn newRdn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name.
      Specified by:
      rename in interface LdapConnection
      Parameters:
      entryDn - the target distinguished name.
      newRdn - new relative distinguished name for the target distinguished name.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
      See Also:
    • rename

      public void rename(String entryDn, String newRdn, boolean deleteOldRdn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name if deleteOldRdn is set to true.
      Specified by:
      rename in interface LdapConnection
      Parameters:
      entryDn - the target distinguished name.
      newRdn - new relative distinguished name for the target distinguished name.
      deleteOldRdn - flag to indicate whether to delete the old relative distinguished name
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
      See Also:
    • rename

      public void rename(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Rdn newRdn, boolean deleteOldRdn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Renames the given entryDn with new relative distinguished name and deletes the old relative distinguished name if deleteOldRdn is set to true.
      Specified by:
      rename in interface LdapConnection
      Parameters:
      entryDn - the target distinguished name.
      newRdn - new relative distinguished name for the target distinguished name.
      deleteOldRdn - flag to indicate whether to delete the old relative distinguished name
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • move

      public void move(String entryDn, String newSuperiorDn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Moves the given entry distinguished name under the new superior distinguished name.
      Specified by:
      move in interface LdapConnection
      Parameters:
      entryDn - the distinguished name of the target entry
      newSuperiorDn - distinguished name of the new parent/superior
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
      See Also:
    • move

      public void move(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Dn newSuperiorDn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Moves the given entry distinguished name under the new superior distinguished name.
      Specified by:
      move in interface LdapConnection
      Parameters:
      entryDn - the distinguished name of the target entry
      newSuperiorDn - distinguished name of the new parent/superior
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • moveAndRename

      public void moveAndRename(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Dn newDn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Moves and renames the given entryDn. The old relative distinguished name will be deleted.
      Specified by:
      moveAndRename in interface LdapConnection
      Parameters:
      entryDn - The original entry distinguished name.
      newDn - The new entry distinguished name.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
      See Also:
    • moveAndRename

      public void moveAndRename(String entryDn, String newDn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Moves and renames the given entry distinguished name. The old relative distinguished name will be deleted
      Specified by:
      moveAndRename in interface LdapConnection
      Parameters:
      entryDn - The original entry distinguished name.
      newDn - The new entry distinguished name.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
      See Also:
    • moveAndRename

      public void moveAndRename(org.apache.directory.api.ldap.model.name.Dn entryDn, org.apache.directory.api.ldap.model.name.Dn newDn, boolean deleteOldRdn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Moves and renames the given entryDn. The old relative distinguished name will be deleted if requested.
      Specified by:
      moveAndRename in interface LdapConnection
      Parameters:
      entryDn - The original entry distinguished name.
      newDn - The new entry distinguished name.
      deleteOldRdn - Tells if the old relative distinguished name must be removed
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • moveAndRename

      public void moveAndRename(String entryDn, String newDn, boolean deleteOldRdn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Moves and renames the given entryDn. The old relative distinguished name will be deleted if requested.
      Specified by:
      moveAndRename in interface LdapConnection
      Parameters:
      entryDn - The original entry distinguished name.
      newDn - The new entry distinguished name.
      deleteOldRdn - Tells if the old relative distinguished name must be removed
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • modifyDn

      public org.apache.directory.api.ldap.model.message.ModifyDnResponse modifyDn(org.apache.directory.api.ldap.model.message.ModifyDnRequest modDnRequest) throws org.apache.directory.api.ldap.model.exception.LdapException
      Performs the modifyDn operation based on the given request object.
      Specified by:
      modifyDn in interface LdapConnection
      Parameters:
      modDnRequest - the request object
      Returns:
      modifyDn operation's response
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • delete

      public void delete(String dn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Deletes the entry with the given distinguished name.
      Specified by:
      delete in interface LdapConnection
      Parameters:
      dn - the target entry's distinguished name, it must be a valid distinguished name.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - If the distinguished name is not valid or if the deletion failed
    • delete

      public void delete(org.apache.directory.api.ldap.model.name.Dn dn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Deletes the entry with the given distinguished name.
      Specified by:
      delete in interface LdapConnection
      Parameters:
      dn - the target entry's distinguished name
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - If the distinguished name is not valid or if the deletion failed
    • delete

      public org.apache.directory.api.ldap.model.message.DeleteResponse delete(org.apache.directory.api.ldap.model.message.DeleteRequest deleteRequest) throws org.apache.directory.api.ldap.model.exception.LdapException
      Performs a delete operation based on the delete request object.
      Specified by:
      delete in interface LdapConnection
      Parameters:
      deleteRequest - the delete operation's request
      Returns:
      delete operation's response
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - If the distinguished name is not valid or if the deletion failed
    • compare

      public boolean compare(String dn, String attributeName, String value) throws org.apache.directory.api.ldap.model.exception.LdapException
      Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.
      Specified by:
      compare in interface LdapConnection
      Parameters:
      dn - the target entry's distinguished name, it must be a valid distinguished name.
      attributeName - the attribute's name
      value - a String value with which the target entry's attribute value to be compared with
      Returns:
      true if the value matches, false otherwise
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • compare

      public boolean compare(String dn, String attributeName, byte[] value) throws org.apache.directory.api.ldap.model.exception.LdapException
      Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.
      Specified by:
      compare in interface LdapConnection
      Parameters:
      dn - the target entry's distinguished name, it must be a valid distinguished name.
      attributeName - the attribute's name
      value - a byte[] value with which the target entry's attribute value to be compared with
      Returns:
      true if the value matches, false otherwise
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • compare

      public boolean compare(String dn, String attributeName, org.apache.directory.api.ldap.model.entry.Value value) throws org.apache.directory.api.ldap.model.exception.LdapException
      Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.
      Specified by:
      compare in interface LdapConnection
      Parameters:
      dn - the target entry's distinguished name, it must be a valid distinguished name.
      attributeName - the attribute's name
      value - a Value<?> value with which the target entry's attribute value to be compared with
      Returns:
      true if the value matches, false otherwise
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • compare

      public boolean compare(org.apache.directory.api.ldap.model.name.Dn dn, String attributeName, String value) throws org.apache.directory.api.ldap.model.exception.LdapException
      Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.
      Specified by:
      compare in interface LdapConnection
      Parameters:
      dn - the target entry's distinguished name
      attributeName - the attribute's name
      value - a String value with which the target entry's attribute value to be compared with
      Returns:
      true if the value matches, false otherwise
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • compare

      public boolean compare(org.apache.directory.api.ldap.model.name.Dn dn, String attributeName, byte[] value) throws org.apache.directory.api.ldap.model.exception.LdapException
      Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.
      Specified by:
      compare in interface LdapConnection
      Parameters:
      dn - the target entry's distinguished name
      attributeName - the attribute's name
      value - a byte[] value with which the target entry's attribute value to be compared with
      Returns:
      true if the value matches, false otherwise
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • compare

      public boolean compare(org.apache.directory.api.ldap.model.name.Dn dn, String attributeName, org.apache.directory.api.ldap.model.entry.Value value) throws org.apache.directory.api.ldap.model.exception.LdapException
      Compares whether a given attribute's value matches that of the existing value of the attribute present in the entry with the given distinguished name.
      Specified by:
      compare in interface LdapConnection
      Parameters:
      dn - the target entry's distinguished name
      attributeName - the attribute's name
      value - a Value<?> value with which the target entry's attribute value to be compared with
      Returns:
      true if the value matches, false otherwise
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • compare

      public org.apache.directory.api.ldap.model.message.CompareResponse compare(org.apache.directory.api.ldap.model.message.CompareRequest compareRequest) throws org.apache.directory.api.ldap.model.exception.LdapException
      Compares an entry's attribute's value with that of the given value.
      Specified by:
      compare in interface LdapConnection
      Parameters:
      compareRequest - the compare request which contains the target distinguished name, attribute name and value
      Returns:
      compare operation's response
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • extended

      public org.apache.directory.api.ldap.model.message.ExtendedResponse extended(String oid) throws org.apache.directory.api.ldap.model.exception.LdapException
      Sends a extended operation request to the server with the given OID and no value.
      Specified by:
      extended in interface LdapConnection
      Parameters:
      oid - the object identifier of the extended operation
      Returns:
      extended operation's response
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
      See Also:
    • extended

      public org.apache.directory.api.ldap.model.message.ExtendedResponse extended(String oid, byte[] value) throws org.apache.directory.api.ldap.model.exception.LdapException
      Sends a extended operation request to the server with the given OID and value.
      Specified by:
      extended in interface LdapConnection
      Parameters:
      oid - the object identifier of the extended operation
      value - value to be used by the extended operation, can be a null value
      Returns:
      extended operation's response
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
      See Also:
    • extended

      public org.apache.directory.api.ldap.model.message.ExtendedResponse extended(org.apache.directory.api.asn1.util.Oid oid) throws org.apache.directory.api.ldap.model.exception.LdapException
      Sends a extended operation request to the server with the given OID and no value.
      Specified by:
      extended in interface LdapConnection
      Parameters:
      oid - the object identifier of the extended operation
      Returns:
      extended operation's response
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
      See Also:
    • extended

      public org.apache.directory.api.ldap.model.message.ExtendedResponse extended(org.apache.directory.api.asn1.util.Oid oid, byte[] value) throws org.apache.directory.api.ldap.model.exception.LdapException
      Sends a extended operation request to the server with the given OID and value.
      Specified by:
      extended in interface LdapConnection
      Parameters:
      oid - the object identifier of the extended operation
      value - value to be used by the extended operation, can be a null value
      Returns:
      extended operation's response
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • extended

      public org.apache.directory.api.ldap.model.message.ExtendedResponse extended(org.apache.directory.api.ldap.model.message.ExtendedRequest extendedRequest) throws org.apache.directory.api.ldap.model.exception.LdapException
      Performs an extended operation based on the extended request object.
      Specified by:
      extended in interface LdapConnection
      Parameters:
      extendedRequest - the extended operation's request
      Returns:
      Extended operation's response
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if the extended operation failed
    • exists

      public boolean exists(String dn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Tells if an entry exists in the server.
      Specified by:
      exists in interface LdapConnection
      Parameters:
      dn - The distinguished name of the entry to check for existence, must be a valid distinguished name.
      Returns:
      true if the entry exists, false otherwise. Note that if the entry exists but if the user does not have the permission to read it, false will also be returned
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • exists

      public boolean exists(org.apache.directory.api.ldap.model.name.Dn dn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Tells if an Entry exists in the server.
      Specified by:
      exists in interface LdapConnection
      Parameters:
      dn - The distinguished name of the entry to check for existence
      Returns:
      true if the entry exists, false otherwise. Note that if the entry exists but if the user does not have the permission to read it, false will also be returned
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • getRootDse

      public org.apache.directory.api.ldap.model.entry.Entry getRootDse() throws org.apache.directory.api.ldap.model.exception.LdapException
      Get back the RooDSE from the connected server. All user and operational attributes are returned.
      Specified by:
      getRootDse in interface LdapConnection
      Returns:
      The Entry containing all the information about the rootDSE
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - If the rootDSE can't be read
    • getRootDse

      public org.apache.directory.api.ldap.model.entry.Entry getRootDse(String... attributes) throws org.apache.directory.api.ldap.model.exception.LdapException
      Get back the RooDSE from the connected server. The user can provide the list of attributes he wants to get back. Sending "*" will return all the user attributes, sending "+" will return all the operational attributes.
      Specified by:
      getRootDse in interface LdapConnection
      Parameters:
      attributes - The list of attributes to return
      Returns:
      The Entry containing all the information about the rootDSE
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - If the rootDSE can't be read
    • lookup

      public org.apache.directory.api.ldap.model.entry.Entry lookup(org.apache.directory.api.ldap.model.name.Dn dn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Searches for an entry having the given distinguished name..
      Specified by:
      lookup in interface LdapConnection
      Parameters:
      dn - the distinguished name of the entry to be fetched
      Returns:
      the Entry with the given distinguished name or null if no entry exists with that distinguished name.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - in case of any problems while searching for the distinguished name or if the returned response contains a referral
      See Also:
    • lookup

      public org.apache.directory.api.ldap.model.entry.Entry lookup(String dn) throws org.apache.directory.api.ldap.model.exception.LdapException
      Searches for an entry having the given distinguished name.
      Specified by:
      lookup in interface LdapConnection
      Parameters:
      dn - the distinguished name of the entry to be fetched
      Returns:
      the Entry with the given distinguished name or null if no entry exists with that distinguished name.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - in case of any problems while searching for the distinguished name or if the returned response contains a referral
      See Also:
    • lookup

      public org.apache.directory.api.ldap.model.entry.Entry lookup(org.apache.directory.api.ldap.model.name.Dn dn, String... attributes) throws org.apache.directory.api.ldap.model.exception.LdapException
      Searches for an entry having the given distinguished name.
      Specified by:
      lookup in interface LdapConnection
      Parameters:
      dn - the distinguished name of the entry to be fetched
      attributes - the attributes to be returned along with entry
      Returns:
      the Entry with the given distinguished name or null if no entry exists with that distinguished name.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - in case of any problems while searching for the distinguished name or if the returned response contains a referral
    • lookup

      public org.apache.directory.api.ldap.model.entry.Entry lookup(org.apache.directory.api.ldap.model.name.Dn dn, org.apache.directory.api.ldap.model.message.Control[] controls, String... attributes) throws org.apache.directory.api.ldap.model.exception.LdapException
      Searches for an entry having the given distinguished name.
      Specified by:
      lookup in interface LdapConnection
      Parameters:
      dn - the distinguished name of the entry to be fetched
      controls - the controls to use
      attributes - the attributes to be returned along with entry
      Returns:
      the Entry with the given distinguished name or null if no entry exists with that distinguished name.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - in case of any problems while searching for the distinguished name or if the returned response contains a referral
    • lookup

      public org.apache.directory.api.ldap.model.entry.Entry lookup(String dn, String... attributes) throws org.apache.directory.api.ldap.model.exception.LdapException
      Searches for an entry having the given distinguished name.
      Specified by:
      lookup in interface LdapConnection
      Parameters:
      dn - the distinguished name of the entry to be fetched
      attributes - the attributes to be returned along with entry
      Returns:
      the Entry with the given distinguished name or null if no entry exists with that distinguished name.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - in case of any problems while searching for the distinguished name or if the returned response contains a referral
      See Also:
    • lookup

      public org.apache.directory.api.ldap.model.entry.Entry lookup(String dn, org.apache.directory.api.ldap.model.message.Control[] controls, String... attributes) throws org.apache.directory.api.ldap.model.exception.LdapException
      Searches for an entry having the given distinguished name.
      Specified by:
      lookup in interface LdapConnection
      Parameters:
      dn - the distinguished name of the entry to be fetched
      controls - the controls to use
      attributes - the attributes to be returned along with entry
      Returns:
      the Entry with the given distinguished name or null if no entry exists with that distinguished name.
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - in case of any problems while searching for the distinguished name or if the returned response contains a referral
      See Also:
    • isControlSupported

      public boolean isControlSupported(String controlOID) throws org.apache.directory.api.ldap.model.exception.LdapException
      Checks if a control with the given OID is supported.
      Specified by:
      isControlSupported in interface LdapConnection
      Parameters:
      controlOID - the OID of the control
      Returns:
      true if the control is supported, false otherwise
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • getSupportedControls

      public List<String> getSupportedControls() throws org.apache.directory.api.ldap.model.exception.LdapException
      Get the Controls supported by server.
      Specified by:
      getSupportedControls in interface LdapConnection
      Returns:
      a list of control OIDs supported by server
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - if some error occurred
    • loadSchema

      public void loadSchema() throws org.apache.directory.api.ldap.model.exception.LdapException
      Loads all the default schemas that are bundled with the API.

      Note: This method enables all schemas prior to loading.
      Specified by:
      loadSchema in interface LdapConnection
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - in case of problems while loading the schema
    • getSchemaManager

      public org.apache.directory.api.ldap.model.schema.SchemaManager getSchemaManager()
      Get the SchemaManager instance
      Specified by:
      getSchemaManager in interface LdapConnection
      Returns:
      The SchemaManager associated with this LdapConection if any
    • getCodecService

      public org.apache.directory.api.ldap.codec.api.LdapApiService getCodecService()
      Gets the LDAP CODEC service responsible for encoding and decoding messages.
      Specified by:
      getCodecService in interface LdapConnection
      Returns:
      The LDAP CODEC service.
    • isRequestCompleted

      public boolean isRequestCompleted(int messageId)
      Checks if a request has been completed, or not.
      Specified by:
      isRequestCompleted in interface LdapConnection
      Parameters:
      messageId - ID of the request
      Returns:
      true if the request has been completed, false is still being processed
    • doesFutureExistFor

      public boolean doesFutureExistFor(int messageId)
      Checks if there is a ResponseFuture associated with the given message ID.
      Specified by:
      doesFutureExistFor in interface LdapConnection
      Parameters:
      messageId - ID of the request
      Returns:
      true if there is a non-null future exists, false otherwise
    • getBinaryAttributeDetector

      public org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector getBinaryAttributeDetector()
      Get the BinaryAttribute dectore instance
      Specified by:
      getBinaryAttributeDetector in interface LdapConnection
      Returns:
      the object responsible for the detection of binary attributes
    • setBinaryAttributeDetector

      public void setBinaryAttributeDetector(org.apache.directory.api.ldap.codec.api.BinaryAttributeDetector binaryAttributeDetecter)
      Sets the object responsible for the detection of binary attributes.
      Specified by:
      setBinaryAttributeDetector in interface LdapConnection
      Parameters:
      binaryAttributeDetecter - The Binary Attribute Detector to use
    • setSchemaManager

      public void setSchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager)
      sets a SchemaManager to be used by this connection
      Specified by:
      setSchemaManager in interface LdapConnection
      Parameters:
      schemaManager - The SchemaManager to set
    • loadSchemaRelaxed

      public void loadSchemaRelaxed() throws org.apache.directory.api.ldap.model.exception.LdapException
      Loads all the default schemas that are bundled with the API, in a relaxed mode.

      Note: This method enables all schemas prior to loading.
      The relaxed mode will allow inconsistencies in the schema.
      Specified by:
      loadSchemaRelaxed in interface LdapConnection
      Throws:
      org.apache.directory.api.ldap.model.exception.LdapException - in case of problems while loading the schema