I always thought that some people were really good at remembering names and stuff, others just sucked at it, and that your ability was determined by your natural memory.
It was a surprise to me then when a good friend of mine with a phenomenal memory for names confessed that he's actually terrible at it. He struggled with it for a really long time and it wasn't until he made a very conscious effort to remember people's names that it started to click.
His trick was to make a point of repeating the person's name at least three times very shortly after hearing it. For him, the act of repeating the name three times makes a huge difference in being able to remember someone's name in the short term.
There's also the sneaky jot-it-into a notebook approach, which is what I've been using for the most part.
If you can remember someone's name in the short term, long term is simply a matter of how much effort you're willing to put into it. If you're not naturally gifted with a great memory, that can involve repetition exercises or writing it down somewhere that you can easily reference.