def _QueryLdap(self, base_dn, ldap_filter, scope=ldap.SCOPE_SUBTREE):
    if not self.conn:
      self._ConnectToAd()

    page_control = controls.SimplePagedResultsControl(
        ldap.LDAP_CONTROL_PAGE_OID, True, (self.page_size, ''))

    failures = 0
    # Iterate over all hosts matching the given ldap_filter, in batches of
    # self.page_size, escrowing each resulting recovery object.
    while True:
      server_controls = [page_control]
      query_id = self.conn.search_ext(
          base_dn, scope, ldap_filter, serverctrls=server_controls)

      try:
        _, results, _, server_controls = self.conn.result3(query_id)
      except ldap.LDAPError:
        failures += 1
        if failures == MAX_QUERY_FAILURES:
          raise
        logging.exception('LDAPError on result3() call.')
        time.sleep(5 * failures)
        self._ConnectToAd()
        continue
      else:
        failures = 0

      for result in results:
        yield result[1]

      # Update page_control with server provided control data, otherwise there
      # are no more results, so break.
      cookie = None
      for server_control in server_controls:
        if server_control.controlType == ldap.LDAP_CONTROL_PAGE_OID:
          _, cookie = server_control.controlValue
          if cookie:
            page_control.controlValue = (self.page_size, cookie)
          break
      if not cookie:
        break
Waits on a VS transaction for the specified amount of time.
dataset/ETHPy150Open google/cauliflowervest/src/cauliflowervest/client/win/bitlocker_ad_sync.py/BitLockerAdSync._QueryLdap--crossover with--dataset/ETHPy150Open softlayer/softlayer-python/SoftLayer/managers/vs.py/VSManager.wait_for_transaction