It is NOT the GM's job to ensure that everyone is having fun, BUT, if no one is having fun, the GM is doing a poor job.
The "having fun" part of gaming is sort of a group responsibility. The game, however, must be played in the right environment to enable the "fun having". And I don't just mean someone's basement versus a game store versus a nice kitchen table. I mean that all of the players are on board with what's going on, people are engaged and feel like they are participating, and so forth. While some of that is on the GM's shoulders, the players bear some responsibility in it as well. Are the players coming to the game in the right frame of mind? Are they paying attention? Are they engaged?
In the final analysis, the "having fun" part of the game, arguably the most important part of the game, is not any one person's responsibility and it's pretty simplistic to believe that it is.
"Having fun" is not always an all-or-nothing proposition, however. Five players could be having a great time while player #6 sulks in the corner. Is that the GM's fault? Probably not. If all of the players are sulking or not paying attention, this is a likely sign of a GM doing a poor job at something. Could be pacing, could be a lack of direction, could be a lack of preparedness. When no one is having fun, that alone could be laid at the GM's feet.