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 Exception => detail
44: if count == 0
45:
46: count += 1
47: @connection = nil
48: Puppet.warning "Retrying LDAP connection"
49: retry
50: else
51: error = Puppet::Error.new("LDAP Search failed")
52: error.set_backtrace(detail.backtrace)
53: raise error
54: end
55: end
56:
57: return found
58: end