Technically, it is not illegal to ask you for it and if you give it to them then you're stuck. But legally you don't have to give it to them and they are obligated to generate a unique ID for your account. SSN can only be used when federal money or taxes are involved, like if you use medical services under medicare. It also is not supposed to be used for driver's license IDs any longer. Some places like hospitals force the issue and demand the number or you don't get services (this is so they can rat you out to the feds if you skip on the bill). It is despicable, but you usually have a choice to take your business elsewhere.
My wife isn't eligeable for a SSN number until our immigration process is complete. She has to use a personal TIN (tax payer identification number). No other agency or private company can require the use of an SSN unless it is for business with the social security administration. You legally can't use it for a driver liscence or for anything else.