This section states that the restrictions don't apply to acts done in carrying out official duties on behalf of the United States or the District of Columbia or as an elected official of a State or local government.
This section also includes a number of other exceptions as well. (Link to 18 U.S.C. 207 for more information)
Let's try to sum all this up...