Here’s some required reading from the military’s Manual of Courts-Martial: "888. ART. 88 Contempt Toward Officials: Any commissioned officer who uses contemptuous words against the President, the Vice President, Congress, the Secretary of Defense, the Secretary of a military department, the Secretary of Transportation, or the Governor or legislature of any State, Territory, Commonwealth, or possession in which he is on duty or present shall be punished as a court-martial may direct."

Gen. Stan McChrystal is undoubtedly a great general, an inspiring leader of men (and women) and a fierce advocate of the new army’s counterinsurgency doctrine. But he needed a better media advisor.

Who persuaded him it was a cool move to give a freelance journalist from Rolling Stone magazine unfettered access to him and his Team America, as his senior aides called themselves? Who failed to set ground rules about what Michael Hastings could, and could not use and how it was to be attributed in his stunning story about the general and his staff? 

How much scotch did his aides consume before they suggested to Vice President Joe Biden “bite me” and started bad-mouthing their civilian counterparts in the Afghan war – rolling their eyes at yet another email from Richard “wounded animal” Holbrooke or accusing Ambassador Karl “dangerous” Eikenberry of trying to divert blame from himself if the War in Afghanistan fails?

After having previously warned Gen. McChrystal about such indiscreet commentary – their first woodshed moment occurred last year after the general during a speech in London disputed Vice President Biden’s recommended policy for Afghanistan – President Obama suggested he had little choice but to force the general’s resignation.

There was no evidence that the two men disagreed about the conduct of the war or the strategy for fighting it. Nor was there any indication that Gen. McChrystal was insubordinate. But as President Obama said today, winning the war in Afghanistan requires a “unity of effort.” There is also an unwritten rule of bureaucracy, and not just in the military: thou shall not mock thy boss or commander-in-chief, at least not in public, or within earshot of a reporter. And you can’t permit your aides to do so either.

For Stan McChrystal, this is a sad ending to a distinguished military career. Appointing

Gen. David Petraeus to replace McChrystal means that President Obama is doubling down on his current strategy. And it still leaves the administration with a set of squabbling civilian aides who keep jockeying for clout and status in time of war. In accepting what in terms of military posts seems like a demotion, Gen. Petraeus, a class act and a war-winner, is being literally a good soldier. He’s taking the job of the general who used to report to him. But that should not be surprising. Gen. Petraeus is a class act. Plus, he is nothing if not media and bureaucracy savvy. So for a while at least, Mr. Obama’s political appointees may find it wise to play well with one another. 

The broader question is whether Mr. Obama is sticking to a losing strategy. Amb Eikenberry may not be a team player, but he may prove right in having asserted (in a cable leaked to The New York Times) that President Hamid Karzai is “not an adequate strategic partner” and that America now risks becoming mired in a country of scant strategic value.

Mr. Obama’s “surge lite” and his fixed time table for starting to withdraw some of those forces next summer may well have been the source of the frustration that led Gen. McChrystal’s Team A to its now legendary indiscretion. Can you blame them?

Judith Miller, a Fox News contributor, is an award-winning writer and author. She spent 85 days in jail in the Alexandria Detention Center in Virginia in 2005 to protect confidential sources.