WASHINGTON — Adultery, fraternization, unbecoming conduct -- The United States' Uniform Code of Military Justice restricts the behavior of soldiers and officers up to the highest ranks.

Still, experts say it seems highly unlikely that either David Petraeus or John Allen -- one a retired general, the other still active -- will be tried in a military court for involvement in a scandal that has shaken Washington.

Petraeus, the most celebrated general of his generation before leaving the military to head he CIA, resigned last week to pre-empt the revelations he had an affair with his biographer, a married woman 20 years his junior.

Currently the top allied commander in Afghanistan, Allen's professional future is now also in question after he was placed under investigation for sending "inappropriate" emails to a married Tampa socialite.

He denies an affair.

Article 134 of the Uniform Code of Military Justice states that "adultery is clearly unacceptable conduct, and it reflects adversely on the service record of the military member."

It is punishable by dishonorable discharge, forfeiture of all pay and allowances and even a one-year prison term.

While Petraeus's liaison seems to span a period when he was no longer in the army, it does not absolve him of the rules of the Uniform Code, said Eugene Fidell, a military law scholar at Yale University.

"Retired regulars who draw pay are subject to the UCMJ, for life," he told Time magazine. "It's not going to happen, but that's what the Manual for Courts Martial provides."

In fact, adultery trials are very rare. In 1999, two-star retired general David Hales admitted before a court martial to adulterous relationships with four wives of his subordinates. He was fined but not jailed.

Adultery not the same as "fraternization," which penalizes any close relationship, especially of a sexual nature, between an officer or non-commissioned officer and a subordinate.

Each year, several cases lead to dismissals.

If the Allen probe confirms Allen had an "inappropriate" correspondence with a woman, he could technically be pursued under the code's Article 133 that punishes "conduct unbecoming an officer and gentleman."

The article defines such bawdy conduct as being the equivalent of being drunk or disorderly in public or associating with prostitutes.