Actually, it is the law:
If he carried on the affair while serving in the Army, however, Patraeus could face charges, according to Article 134 of the Uniform Code of Military Justice, which reprimands conduct "of a nature to bring discredit upon the armed forces."
You seem to believe that the only laws and rules that need to be followed are the rules that you personally believe in.