Whether you use a or an is entirely decided by the sound of the following word, and doesn't necessarily have anything to do with the spelling of the following word. Words like uniform or user are pronounced with an initial "y" sound (a palatal glide), and so it's correct to say a uniform, a user. Saying an uniform, an user is incorrect.