Both are ok and very polite way in formal to ask others' name. In a informal situation, you can say 'ni jiao shenme mingzi?' or 'ni de mingzi jiao shenme?'. There are still a lot of way to ask somebody's name, and some of them are impolite, like 'ni shi shui?' or 'ni shui ya?', but it also depends on the way you how to say it and the person you are talking to, so you should be very careful of your tongue.
Hope you enjoy Chinese. ^_^