I don't know if this story is accurate or not and I really hate to defend Obama. BUT, he IS the COMMANDER IN CHIEF. He can order any soldier, Marine, airman, or sailor not to speak at a public function.
Like it or not, when you sign the dotted line, you give up your rights to freedom of speech for the length of that contract. Right or wrong, that's the way it is.