Thanks to the National Conference of State Legislatures for this item that was published by the Department of Defense eight years ago.
The Department of Defense issued a directive in 2008 regarding political activity by members of the military. This section refers specifically to “holding and exercising the functions of a state or other non-U.S. government office attained by election or appointment.”
4.5.1. Paragraph 4.5. applies to a civil office in a State; the District of Columbia; a territory, possession, or commonwealth of the United States; or any political subdivision thereof.
4.5.2. A regular member may not hold or exercise the functions of civil office unless otherwise authorized in paragraph 4.5. or by law.
4.5.3. A retired regular or Reserve Component member on active duty under a call or order to active duty for more than 270 days may hold─but shall NOT exercise─the functions of a civil office as set out in subparagraph 4.5.1., as long as:
184.108.40.206. The holding of such office is not prohibited under the laws of the State; the District of Columbia; a territory, possession, or commonwealth of the United States; or any political subdivision thereof.
220.127.116.11. The Secretary concerned grants permission after determining that holding such office does not interfere with the performance of military duties. The Secretary concerned may NOT delegate the authority to grant or deny such permission.
4.5.4. A retired regular or Reserve Component member on active duty under a call or order to active duty for 270 days or fewer may hold and exercise the functions of civil office provided there is no interference with the performance of military duties.
4.5.5. Any member on active duty authorized to hold or exercise, or not prohibited from holding or exercising, the functions of office under paragraph 4.5. is still subject to the prohibitions of subparagraph 4.1.2.
Many civilians might not distinguish between active-duty and retired military which can be confusing when listening to news stories where former service members offer their backing and implied military expertise to political candidates.
A good example are two reports on NPR this morning:
Registered independent, retired Air Force Gen. Lloyd Newton, announced his endorsement of Democrat Hillary Clinton. Scores of retired military officers endorsed Donald Trump on Tuesday.
88 former military leaders endorse Donald Trump: In an open letter, they said they believe America needs a leader who has not been deeply involved with the hollowing out of the military. Steve Inskeep talk to retired Rear Admiral Philip Anselmo.