code: def where_node_as_ldap(where, compiler, connection):
      
      bits, params = [], []
      for item in where.children:
          if isinstance(item, WhereNode):
              clause, clause_params = compiler.compile(item)
          else:
              clause, clause_params = item.as_sql(compiler, connection)
  
          bits.append(clause)
          params.extend(clause_params)
  
      if not bits:
          return '', []
  
      # FIXME(rbarrois): shouldn't we flatten recursive AND / OR?
      if len(bits) == 1:
          clause = bits[0]
      elif where.connector == AND:
          clause = '&' + ''.join('(%s)' % bit for bit in bits)
      elif where.connector == OR:
          clause = '|' + ''.join('(%s)' % bit for bit in bits)
      else:
          raise LdapDBError("Unhandled WHERE connector: %s" % where.connector)
  
      if where.negated:
          clause = ('!(%s)' % clause)
  
      return clause, params
docs: Parse a django.db.models.sql.where.WhereNode.
  
      Returns:
          (clause, [params]): the filter clause, with a list of unescaped parameters.