I think you're talking about Chamber of Secrets when Tom Riddle's diary shows Harry the time when the Chamber was open the first time and Tom made sure suspicion fell on Hagrid. Dumbledore knew Hagrid didn't do it. When the Chamber is opened during Harry's second year, Hagrid is again suspected but his name is cleared when Harry proves Ginny opened the Chamber under the influence of the diary.
|