Not sure about legality, but most ticket sellers try to stop them - usually via those annoying things where you have to type a word you can barely read. It never seems to work though. There are moves to change the law here as well, but it's a difficult process I guess.
Best way around it I ever saw was when Rage Against The Machine got the xmas number one, and did a free gig by way of a thank you. When you applied for tickets, you had to submit a photo of each person you were applying for, and then they were printed on the tickets. Security checked the tickets on the way in, so I guess you could sell to someone that looked a bit like you, but it certainly prevented this anonymous online selling.