FAIRFIELD — Stephen Buchanan was on the list to become a Stratford police officer. But when he pulled up in front of the local home where he thought a 13-year-old girl lived last October, police said it had nothing to do with law enforcement.

The 27-year-old Buchanan pleaded guilty Thursday at state Superior Court in Bridgeport to attempted second-degree sexual assault, attempted risk of injury to a minor and attempting to entice a minor in an obscene act.

Superior Court Judge Robert Devlin said he would impose a sentence of up to three years in prison on Buchanan when he is sentenced July 1.

Defense lawyer Michael Fitzpatrick said he would reserve comment on the case until the sentencing hearing.

Buchanan, a member of the Connecticut National Guard until his arrest, was one of 10 men snagged in a sting at a house in Fairfield. The sting, set up by television personality Chris Hansen, Fairfield police and State’s Attorney John Smriga, arranged for Fairfield University theater students to pose online as 13-year-old boys and girls. When the suspects showed up at the house to have sex with the teenagers, they were arrested, and the incidents were video recorded for a planned television program.

Senior Assistant State’s Attorney Ann Lawlor told the judge that after police took Buchanan into custody at the home where the sting was staged, they found a loaded gun, a roll of duct tape and a knife in a bag in his car.