An ex-Alabama state trooper who was accused of raping a woman while he was on duty has been sentenced to six months in jail after he pleaded guilty to sexual misconduct.

Samuel McHenry II filed a plea agreement in Butler County District Court on Thursday during a preliminary hearing.

Charges of rape and sodomy that were filed against him have been dismissed.

Court documents say McHenry drove a woman away from the scene of a car accident in early December and threatened to take her to jail if she didn't have sex with him. McHenry was later fired and arrested.

Under the plea agreement, McHenry's Alabama Peace Officers' Standards and Training Commission certification will be revoked and he'll have to register as a sex offender.