Biocidal composition, which comprises at least one ionic, polymeric compound comprising imidazolium groups (imidazolium compound), which can be obtained by reacting a) at least one α-dicarbonyl compound of the formula (I) R1-CO-CO -R2 (I) in which R1 and R2 are independently selected from hydrogen and in each case alkyl, alkoxy, alkylthio, cycloalkyl, cycloalkoxy, cycloalkylthio, aryl, aryloxy and unsubstituted or substituted arylthio, b) at least one aldehyde of formula (II) R3-CHO (II) in which R3 is selected from hydrogen, C1-C20 alkyl, C3-C8 cycloalkyl, optionally substituted aryl and a radical of the formula -CH2- [O-CH2CH2] xORa, in which x is 1, 2, 3, 4, 5 or 6 and Ra is hydrogen or C1-C4 alkyl, c) at least one amino compound having at least two primary amino groups, d) optionally an amino compound that it has only one primary amino group and e) at least one protic acid, and optionally subject the reaction product to an anion exchange, in which in components a) and b) aldehyde carbonyl groups may also be present as hemiacetal or acetal and ketone carbonyl groups may also be present as hemicetal or ketal; wherein the main chain of at least one compound comprising imidazolium groups does not contain 1,4-bonded phenylene rings; wherein the amino compound having at least two primary amino groups is not 1,3-diamino-2-hydroxy propane or 1,3-diamino-2-hydroxy-2-methyl propane; and wherein the polymer comprises at least 8 imidazolium rings; and at least one vehicle and / or at least one auxiliary agent; wherein component c) is selected from - amines of the formula 1 H2N-A-NH2 (1) in which A is a divalent aliphatic, alicyclic, aliphatic-alicyclic, aromatic or araliphatic radical, in which the aliphatic fractions in the aliphatic, aliphatic-alicyclic or araliphatic radicals mentioned above can be interrupted by one or more non-adjacent groups that are selected from -O-, -S- and -N (Rb) -, in which Rb is selected from hydrogen, C1-C20 alkyl and a group - [- CH2CH2-O -]