When is it acceptable to write a bad letter of recommendation? For reasons that elude me, a student I taught several semesters ago sounded me out about writing a letter of recommendation for graduate school. I won't go into it, but my recollections of this student are uniformly bad. There is no way I would want them pursuing graduate study in our department. I am torn between declining to write a letter, or taking the opportunity to quietly warn colleagues at other institutions about this person. Do I have an ethical duty to only offer to write a letter if it will reflect positively on the applicant?
Never write a bad recommendation letter. If you can't say anything nice, say nothing at all (and tell the student you can't write the letter).

As for warning other. Leaving aside the law for a moment, the only time I can see it being appropriate to warn others about a student is if you believed them to be dangerous. Examples of this might be a history of sexual harassment/assault, bullying or other abusive behaviour.