Heinlein did not like the counter culture that he helped create. In fact, he went out of his way to distance himself from it. He was a crypto-fascist at heart, and would have been right at home in today's American Tea Party. He would denounce them for their racist and sexist morality, to be sure, but their idea of a society ruled by elites that use their economic and politcal power to maintain control over their society is something he would have heartily agreed with. His novels are rife with that kind of elitism, and there are echoes of it in Trek, especially in TNG.
Heinlein was a great story teller, and his stories helped elevate SF from the pulp ghetto to mainstream literature, especially novels like SiaSL and ST. But don't be tempted to think Heinlein the political man is the same as Heinlein the author. I grew up on a steady diet of Heinlein's juveniles, and was blown away by SiaSL when I read it for the first time at the ripe old age of twelve. I was (and still am, to a large extent) a Heinlein fan boy, but I've learned that my politics and Heinlein's are not equivalent, and are in fact diametrically opposed. It's tempting think that an author who entertains and delights you shares your politics, but that is not the case with Heinlein. There is no way Heinlein can be expected to rationally hold the opposing ideologies that permeate some of his best work. He was embraced on the left (over his strenuous and public objections at the time) by counter culture hippies who saw in Stranger in a Strange Land a blueprint for a better human civilization. But the same Heinlein that taught the human race how to grok also was embraced by libertarians who saw his novel The Moon is a Harsh Mistress as a part of their Ayn Rand wet dream. There is no way Heinlein the man could champion both of these ideologies simultaneously and be taken seriously by anybody.
As I've come to understand them, the only novel that really reflects Heinlein's personal politics is Starship Troopers. It distills Heinlein's fascism and reflects his very real political conviction that the State is the only thing that stands between civilization and chaos, and that the only way to deal with an enemy is to destroy him, if you think you can't win him over to your side. Detente was not in his book of tactics, nor was the idea of live and let live. Check out his speech to the 1960 WorldCon in Seattle if you need further evidence of Heinlein's real politics.
ST was a morality play about duty, and a call to arms, and it was a doozy. No wonder Paul Verhoeven, when he was looking to skewer the reflowering of Euro-fascism in the 1990s, chose ST for its very fascist themes.
Even before that infamous speech, Heinlein was involved with rightwing politics in the US, even forming the "Patrick Henry League" to counter calls for nuclear disarmament. After that WorldCon, he became a vocal supporter of Barry "We can win a nuclear war" Goldwater for president in 1964, hosting a number of fund raising dinners for him. For Heinlein, the US not using their nuclear capability to finish off the Soviets after Nazi Germany had severely weakened them and the US had it's only window of nuclear superiority was a far greater sin than any fallout (pun intended) resulting from turning Moscow into a glow-in-the-dark parking lot.
So be careful lionizing somebody for the politics they espouse in their fiction -- Heinlein's gift as a writer was in knowing his audience and knowing which levers he needed to pull, and which ones only needed a nudge. His politics are more in line with the junta that seized control of Earth's governments in ST than with the free-love anarcho-messiah Michael Valentine Smith in SiaSL.