In Harry Potter and the Chamber of Secrets when Dobby uses the Hover charm, Harry is warned that he isn't supposed to do magic outside school.
However, it was Dobby who did the magic.
Don't they know who exactly does magic? What if some grown-up wizard came to Hermione's family and did magic in the presence of the muggles, would they immediately suspect Hermione and send her an owl?
Besides that, Harry could have gone to court against the ministry and presented his wand so they would check to know that his last spell wasn't the Hover charm. As far as I know it is possible and he wouldn't be guilty.
Yet, in the 2nd or 3rd movie Harry does the Lumos charm under his blanket, isn't that disallowed too?
So, my thought is that the ministry has problems with spotting magic and the rest.
I'm asking why they thought Harry did it and why they sent him a warning when they should have done an inquiry first and therefore would know that it indeed wasn't Harry who cast the spell.