If you're looking for a legal solution then it's simple: enact a law. Just make it so that anyone can come forward to file a complaint about being the target of magic against their will, or in the case of necromancy that someone in their family was the target of magic against their will. Proving it might be difficult, but that's the same with a lot of laws.
Now that you've got a law on the books, the next phase is to add a regulation framework for all mages. Any mage that wants to practice their magic requires a licence, and unlicenced practitioners will be prosecuted severely. Schools will of course have a licence that covers their students, allowing them to practice on the school grounds with the school responsible for any problems that arise.
Then you just have to tighten up the regulation of magic to the point where mages are required to record every magical expenditure, with random auditing and penalties. Proctors will randomly drop in on mages at work, at home, random mana tests, etc. to check their logs against their current mana levels. Any inconsistency will result in the mage losing their licence for a period. Multiple breaches will ultimately result in a permanent bad from performing magic.
Of course manually recording every single mana point spent is just tiresome, and if you're in the middle of a long process when the proctors turn up, you can't just get away with "I'm busy, I'll record it later." That's a fantastic way to end up out of a job when they suspend your licence. So now we have an opportunity to introduce automatic recording devices - pendants, rings or similar - that monitor every spell you cast so that you don't have to.
And now we have them. The mage who casts a Greater Mass Healing in a crowd? He's going down, and hard. He just broke a bunch of laws and is going to be stripped not just of his licence but his freedom. Damned dirty mage deserves everything he's about to get, especially since his 'monitor' bracelet just locked down his mana and shocked him unconscious.
OK, I'm apparently in a dark mood. Let's try an alternate method, a little less autocratic. Let's use some magic to solve the problem.
Every living creature has some sort of magical field - let's call it an aura. With the right tools we can examine this field to figure out how magically capable a creature has, and maybe even figure out what sort of magical abilities they are best at. Schools use this to identify students with particularly high aptitudes in specific disciplines. Every aura is unique at the finest level of detail, more so than any fingerprint.
When a mage casts any spell their aura imprints a signature on the spell's energy. It's extremely subtle, and any significant 'turbulence' in the magic - such as the constantly roiling energy of an elemental damage spell for instance - will disrupt it to some degree, but if you can examine the spell's effect locus (fancy mage speak for the area it affects) quickly enough after the spell ends then it is possible to identify the mage who cast the spell. It's a lot easier if you can capture the signature of a spell while it is in operation, making it quite useful for fingerprinting enchantments and so on.
If the target of a spell also has an aura then the incoming spell's signature is partially imprinted on the part of the aura it passes through. Again, direct damage spells are less likely to leave the aura intact enough to read, but even simple protection spells leave a signature on the target's aura.
Of course an aura isn't just a static field like you might get on an artifact, it's generated by the life force of the creature itself, and the creature's state affects the aura in various ways. One way is that the aura becomes more or less permeable to magic depending on the creature's will. If you want that spell to affect you then your aura opens the door, invites the spell in and makes it comfortable. But if you're opposed? Then your aura - weak, ephermeral and inefficient though it may be - attempts to shut the spell out. Some creatures have the ability to actually block spells with their aura, which we perceive as innate magic resistance. Humans can do the same with sufficient training and power, or with the help of the right spells and artifacts.
The end result of all of this is that a scan of a person's aura can, for a limited time only, determine not only that a spell was cast but what the spell was, who cast it and whether the target was willing, unwilling or indifferent.
Of course this information isn't necessarily public knowledge. It was discovered by a small team of Theoretical Divinators who thought it was kind of nifty, but not really what they were after. One of them made a few notes that went unpublished for years, only being found after he threw himself off a cliff shortly after a divination experiment went wrong and he caught a glimpse of a communal shower in one of the negative planes. Poor chap.
Fortunately for law enforcement agencies around the world, these notes eventually fell into the hands of a young artificer specializing in scrying and detection magics. She eventually figured out that not only was it useful but she could make a tidy sum sell magic items to trackers and magical investigators. Frindley's Aura Loup is now one of the standard pieces of equipment for anyone investigating magic-related shenanigans, and no self-respecting magical police force would be without the related Signature Storage Orb in their office.
So... Mage $A$ casts a healing spell on a group and incautiously includes some innocent bystander $B$ in the area of effect. Now $B$ has been excused from certain activities - like guarding and so forth - due to a wound sustained during a goblin attack some months back, and really didn't want his excuse to suddenly disappear. He complains to Corporal $C$ who, dutiful enforcer of the law that he is, pulls the signature of the spell from $B$'s aura. It is quickly matched with $A$'s signature and a fine is issued. Sadly $B$ was unable to turn up to the court date as he was valiantly lost during the ogron attack the next day, but $A$ was clearly guilty of unsolicited healing and failure to adequately contain a class-3 spell whilst inside the city walls. We trust that he is sufficiently chastised.
Sadly, corpses are not quite so simple. We can figure out who cast the spell, but it's their word against the family that it was illicitly cast. Time to go through the Will with a fine-toothed lawyer.
Comb? Why use would a comb be on a Will? Stop being daft and fetch Mr Vlad.