A Camden County detective accidentally shot and wounded himself Friday morning while using the bathroom in his office, authorities said.

He was seated or about to sit when the gun fired, the shot hitting him in the leg, said Jason Laughlin, spokesman for the Camden County Prosecutor's office. The gun was out of the detective's holster at the time.

The detective's name was not released. He is part of the office's narcotics unit, Laughlin said, and has been with the prosecutor's office for several years.

Taken to Cooper University Hospital, the detective underwent surgery and is "expected to be alright," Laughlin said.

The accident occurred inside the Camden building that houses the L-3 Communications defense contractor, where the company works on communication systems for "space, ground, air and naval operations," according to the L-3 website. Several law enforcement agencies, including the prosecutor's office, also have space in the tightly-guarded complex.

A review will be conducted, Laughlin said, to determine how the shooting occurred.