Class LdapSearch

  • Direct Known Subclasses:
    DsmlSearch, LdifSearch

    public class LdapSearch
    extends java.lang.Object
    LdapSearch queries an LDAP and returns the result. Each instance of LdapSearch maintains it's own pool of LDAP connections.
    Version:
    $Revision: 1330 $ $Date: 2010-05-24 00:10:53 +0200 (Mon, 24 May 2010) $
    Author:
    Middleware Services
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected LdapBeanFactory beanFactory
      Ldap bean factory.
      protected org.apache.commons.logging.Log logger
      Log for this class.
      protected LdapPool<Ldap> pool
      Ldap object to use for searching.
    • Constructor Summary

      Constructors 
      Constructor Description
      LdapSearch​(LdapPool<Ldap> pool)
      This creates a new LdapSearch with the supplied pool.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Empties the underlying ldap pool, closing all connections.
      protected void finalize()
      Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
      LdapBeanFactory getLdapBeanFactory()
      Returns the factory for creating ldap beans.
      java.util.Iterator<javax.naming.directory.SearchResult> search​(java.lang.String query, java.lang.String[] attrs)
      This will perform an LDAP search with the supplied query and return attributes.
      void search​(java.lang.String query, java.lang.String[] attrs, java.io.Writer writer)
      This will perform an LDAP search with the supplied query and return attributes.
      void setLdapBeanFactory​(LdapBeanFactory lbf)
      Sets the factory for creating ldap beans.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        protected final org.apache.commons.logging.Log logger
        Log for this class.
      • pool

        protected LdapPool<Ldap> pool
        Ldap object to use for searching.
    • Constructor Detail

      • LdapSearch

        public LdapSearch​(LdapPool<Ldap> pool)
        This creates a new LdapSearch with the supplied pool.
        Parameters:
        pool - LdapPool
    • Method Detail

      • getLdapBeanFactory

        public LdapBeanFactory getLdapBeanFactory()
        Returns the factory for creating ldap beans.
        Returns:
        LdapBeanFactory
      • setLdapBeanFactory

        public void setLdapBeanFactory​(LdapBeanFactory lbf)
        Sets the factory for creating ldap beans.
        Parameters:
        lbf - LdapBeanFactory
      • search

        public java.util.Iterator<javax.naming.directory.SearchResult> search​(java.lang.String query,
                                                                              java.lang.String[] attrs)
                                                                       throws javax.naming.NamingException
        This will perform an LDAP search with the supplied query and return attributes.
        Parameters:
        query - String to search for
        attrs - String[] to return
        Returns:
        Iterator of search results
        Throws:
        javax.naming.NamingException - if an error occurs while searching
      • search

        public void search​(java.lang.String query,
                           java.lang.String[] attrs,
                           java.io.Writer writer)
                    throws javax.naming.NamingException,
                           java.io.IOException
        This will perform an LDAP search with the supplied query and return attributes. The results will be written to the supplied Writer.
        Parameters:
        query - String to search for
        attrs - String[] to return
        writer - Writer to write to
        Throws:
        javax.naming.NamingException - if an error occurs while searching
        java.io.IOException - if an error occurs while writing search results
      • close

        public void close()
        Empties the underlying ldap pool, closing all connections. See LdapPool.close().
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable - if an exception is thrown by this method