A former Sonoma County sheriff's deputy and Petaluma police officer was sentenced to 50 years in prison Wednesday in Maryland for attempted rape and burglary.

Ricky Bostic, 44, was hired by the Petaluma Police Department in 1998 after graduating from the Napa police academy, said a friend of his who asked that his name not be printed.

Bostic became Petaluma's first African-American patrol officer in 1999. He was on the SWAT team and was considered a "good cop." He left Petaluma on good terms, the friend said, to take a job at the Sheriff's Office.

County records show he was hired in April 2001 and left in May 2009.

In 2005, Bostic was involved in the death of a suspect who was shocked with a Taser while fighting with deputies. The man's death, the county's second involving a Taser stun gun, prompted changes in the Sheriff's Office's training guidelines for using the electric zapping devices.

Bostic and the other deputies were cleared of any wrongdoing in the incident.

A former colleague of Bostic's at the Sheriff's Office said Bostic began having alcohol troubles at some point, which led to his departure from the agency.

Sonoma County court records show Bostic was convicted of drunken driving on April 14, 2009. He was sentenced to three years probation.

The county colleague said Bostic resigned after violating a substance-abuse contract he signed with the county after a prior alcohol-related incident.

After leaving Sonoma County, Bostic moved to Maryland.

In 2012, he was charged in connection with two sexual assaults, several burglaries and trespassing in Baltimore County.

Baltimore County police linked Bostic to the crimes with fingerprints, DNA and a cellphone camera with pictures of one of the victims taken before she awoke, the Baltimore Sun reported.

Police said they recovered victims' property — including credit cards, Xbox and Wii gaming systems, and a laptop computer — in Bostic's possession.

Bostic had worked as a security guard at Greater Baltimore Medical Center, the Sun reported.

On Wednesday, Bostic was convicted of breaking into a residence on May 24, 2012, and sexually assaulting two women in separate rooms of the home. Police tied Bostic to six other burglaries and another sexual assault over a 56-day period that summer.

He was arrested after he attempted to open a sliding glass door at an apartment complex, causing a woman asleep on the couch inside to wake up and call for her boyfriend.

You can reach Staff Writer Lori A. Carter at 762-7297 or lori.carter@pressdemocrat.com.