A retired NYPD detective was busted last night for posing as the director of a city agency in order to score free entry to a $1,100-a-seat awards dinner at a swank Midtown hotel, authorities said.

Allen Caplan, 52, allegedly told officials at the Institutional Investor Magazine’s Second Annual U.S. Investment Management Awards, being held at the Mandarin Oriental hotel, that he was “David Kanovitz,” director of the Financial Information Services Agency (FISA).

The evening honors financial professionals for their achievements in the investment field.

There was just one big glaring hole in Caplan’s story: there is no “Kanovitz” at FISA and the agency had no reason to attend the ritzy gala, authorities said.

Caplan, a 25-year vet who served from January 1984 through February 2009, was spied at the event by an undercover investigator identifying himself as “Kanovitz,” and sporting an ID badge with the same name on his jacket pocket.

Caplan was so committed to the ruse that under questioning he allegedly told the undercover he was from the “City of New York.”

Prior to the event, Caplan had sent an organizer an email identifying himself as “Kanovitz,” authorities said. Event officials reached out to FISA, who in turn notified the city’s Department of Investigation.

Caplan was arrested early this morning and charged with attempted grand larceny and criminal impersonation.

“The defendant fraudulently used the name of a City agency to gain free access to an expensive, private sector financial awards dinner, according to the criminal complaint. Impersonating a City official can have a variety of problematic consequences, which is why it is a crime,” said DOI Commissioner Rose Gill Hearn.