WELLINGTON, New Zealand — A New Zealand court on Friday revealed the name of a high-ranking military envoy who was accused of surreptitiously recording his co-workers in a bathroom at the New Zealand Embassy in Washington.

Alfred Keating, 58, was charged in March after New Zealand police officers traveled to the United States to conduct an investigation, pre-empting an American criminal case from which Mr. Keating could claim diplomatic immunity.

Before he resigned in March, Mr. Keating was a commodore in the Royal New Zealand Navy. He had been the country’s most senior military attaché stationed in the United States. Upon returning to New Zealand in November, he was charged with attempting to make an “intimate visual recording,” a crime that carries a maximum 18-month prison term if he is found guilty.

According to court documents, a camera was discovered in July in a unisex toilet at the embassy, used by about 60 staff members, after it fell on the floor.