An ongoing FBI inquiry into Hillary Clinton's private email server has dogged the Democratic presidential candidate on the campaign trail.

Federal agents want to know if any U.S. secrets were compromised through Clinton's unusual set-up when she worked as secretary of state. Clinton has not been named as a target of the FBI probe. But there's a long history of top officials getting scrutiny over classified information (see below).

In 2012, David Petraeus was forced to resign as Director of the Central Intelligence Agency after the FBI uncovered an affair with his biographer, who was also his mistress. Shortly after, federal agents found he allowed her to read his top secret diaries. Those black notebooks contained war plans and names of covert operatives.

In court papers, prosecutors said Petraeus initially lied to the FBI about it. Last year, a federal judge sentenced him to probation on a single misdemeanor count of mishandling classified intelligence.

And years earlier, there was this: Samuel "Sandy" Berger, the former national security adviser to President Bill Clinton, admitted to intentionally taking classified documents from the National Archives, stuffing those papers into his clothes and eventually, destroying them. Berger also got probation after his misdemeanor plea.

But few top officials ever face criminal prosecution for breaking the rules or the laws on classified information.

There's a reason for that, according to secrecy expert Steve Aftergood at the Federation of American Scientists.

"There's a hierarchy," Aftergood said. "The secretary of state, for example, has been personally delegated presidential authority to decide what is classified and what can be declassified. Someone who's two or three tiers below her in the bureaucracy does not have that same authority."

Longtime defense lawyer Abbe Lowell has often criticized the system as being arbitrary, rife with double standards depending on where a government official sits on the ladder. But Lowell said there are a few common threads he can find in who actually gets prosecuted, like whether the official is focused on doing government business, or his own business.

"You're generally dealing with an official who should have known better," Lowell said. "So the national security adviser should know better than to take documents out of a secured location to make it convenient for him to work from home. The head of the CIA should know better than to provide notebooks filled with some material that is at least sensitive if not higher than sensitive to somebody writing a book about him and with whom he has a relationship."

Lowell said the laws on misusing classified information address "first and foremost" actual spying, or evidence of real damage to national security, rather than technical violations of the law.

One instance of that emerged in 2008, when the Justice Department's inspector general found that former Attorney General Alberto Gonzales mishandled secret documents.

Investigators said Gonzales improperly stored notes on some of the most sensitive issues in the George W. Bush presidency: the detainee interrogation program and the warrantless wiretap program. But no one outside the government apparently got their hands on the materials, and the Justice Department declined to prosecute him.

That makes sense to former prosecutor Amy Jeffress.

"There are many other alternatives for people who violate these rules and criminal punishment should only be used in the most serious cases," Jeffress said.

That means, she said, targeting officials who had a bad intent for charges that carry jail time, and yanking security clearances or firing employees for lesser offenses.

Copyright 2016 NPR. To see more, visit http://www.npr.org/.