I suppose programs could have their own rules, but my experience/recollection has been that the hospital or GME had a broad policy that residents fall under. I expect institutions to have different policies. That said, a pre-employment UDS seems to be very, very common. After that, not so much unless there is a specific issue, local policy, or separation of employment for some reason and then you return. But, I seem to recall that most have some sort of clause that says they can do it again for cause/suspicion/whatever. I've seen docs who probably told folks to spare them, at one point or other. One eventually manned up and by available accounts is successful and happy. Another killed someone in an MVA -- not entirely sure if they stayed out of jail for the long term, but at best it certainly hampers their job prospects. Of course, right about now the user/abuser/dabbler doesn't care about that, or rather, prefers to assume the best for and about themselves.
What I, or you, think about these things in terms of current law or societal acceptance is, I think, another topic. Certainly different substances -- currently legal or illegal or prescription only or whatever -- appear to have different risk profiles, but for the most part the law seems to be pretty clear on most of it, abuse of your own prescriptions possibly withstanding. But I'm no lawyer.