It's a good question. There's two parts to it, whether the law allows for that, and whether or not the law should allow for it?
There are certainly some classes of items/products/services that allow X to legally bar Y from selling it to Z: airline tickets, sub-leasing apartments, software etc.