# File lib/active_ldap/adapter/jndi_connection.rb, line 102
      def search(base, scope, filter, attrs, limit, callback, &block)
        controls = SearchControls.new
        controls.search_scope = scope

        if attrs && !attrs.empty?
          controls.returning_attributes = attrs.to_java(:string)
        end

        i = 0
        @context.search(base, filter, controls).each do |result|
          i += 1
          attributes = {}
          result.attributes.get_all.each do |attribute|
            attributes[attribute.get_id] = attribute.get_all.collect do |value|
              value.is_a?(String) ? value : String.from_java_bytes(value)
            end
          end
          callback.call([result.name_in_namespace, attributes], block)
          break if limit and limit <= i
        end
      end