32: def ldapsearch(filter)
33: raise ArgumentError.new("You must pass a block to ldapsearch") unless block_given?
34:
35: found = false
36: count = 0
37:
38: begin
39: connection.search(search_base, 2, filter, search_attributes) do |entry|
40: found = true
41: yield entry
42: end
43: rescue SystemExit,NoMemoryError
44: raise
45: rescue Exception => detail
46: if count == 0
47:
48: count += 1
49: @connection = nil
50: Puppet.warning "Retrying LDAP connection"
51: retry
52: else
53: error = Puppet::Error.new("LDAP Search failed")
54: error.set_backtrace(detail.backtrace)
55: raise error
56: end
57: end
58:
59: found
60: end