Information on the cameo
Professor Gilderoy Lockhart is a character from the Harry Potter franchise. He first appeared in Harry Potter and the Chamber of Secrets (movie and book, being portrayed by Kenneth Branagh in the former) and returned in Harry Potter and the Order of the Phoenix (book only). In the Harry Potter books, Lockhart received many prestigious awards such as Order of Merlin, Third Class; Honorary Member of the Dark Force Defense League; and five-time winner of Witch Weekly's Most Charming Smile Award.
Lockhart is a famous celebrity who has written many books about his supposed encounters with dark creatures and claimed that he did many daring deeds; in actuality, he erased the memories of the people who really did accomplish those feats and claimed that he was the one who accomplished them. He was also a Defense Against the Dark Arts Professor at Hogwarts for a year, before accidentally erasing his own memory. Although cocky and smarmy, he is adored the world over by witches of all ages who are impressed with his legendary feats.
Appearance in the rap battle
In the rap battle, Gilderoy Lockhart appeared after Dumbledore said the line, "I prefer the company of wizards, and I'm proud of it!", being pulled onstage holding a moving picture frame of himself. Dumbledore pushes him away after this line, and he returns at the end when Dumbledore said the line, "And when I'm finished, I'mma fly like it's Quidditch!", flying off with Dumbledore on a broomstick with a pink scarf, a very stereotypical clothing for gays, referring to Dumbledore being homosexual. He was also seen during the final ending sequence at the end of the battle.