def search(options={}, &block)
super(options) do |base, scope, filter, attrs, limit, callback|
begin
i = 0
info = {
:base => base, :scope => scope_name(scope),
:filter => filter, :attributes => attrs,
}
execute(:search, info, base, scope, filter, attrs) do |entry|
i += 1
attributes = {}
entry.attrs.each do |attr|
attributes[attr] = entry.vals(attr)
end
callback.call([entry.dn, attributes], block)
break if limit and limit <= i
end
rescue RuntimeError
begin
@connection.assert_error_code
rescue LDAP::ServerDown
raise ConnectionError, $!.message
end
if $!.message == "no result returned by search"
@logger.debug do
args = [filter, attrs.inspect]
_("No matches: filter: %s: attributes: %s") % args
end
else
raise
end
end
end
end