Solution in 4 parts:
First part: The government makes and grows the drugs themselves, ensuring quality control. When drugs are sold by streetgangs, they try to make asmuch profit as possible, trying to maximize profits. Whereas the governments only concern is that of the health of their citizens (ok not really but idealy). The government could also outsource this to create jobs. There needs to be VERY strict control on these companies though.
Second part: the government sets up 'drugstores' that sell every type of drug. You will need to be registered to buy from these stores so they can see, when, how much and what you buy as a means to make sure it's drug use and not drug abuse. Amounts will be limited to a certain quantity determined by a study of chemist, biologist and physycians to determine what a safe amount would be (as in regards to addiction problems).
third part: EDUCATION AND NOT MISINFORMATION. What I see when I see anti-drug ads and campaigns is that they're usualy based on lies and misinformation. 'Take this drug and you'll get addicted'. 'Take this drug and you'll probably overdose'. etc .. What this does is creating false expectations with kids and teenagers, who when they come in contact with drugs see that they've been lied to. So they say 'fuck just say no' and just stupidly do everything. There needs to be a special drugclass (and not some stupid D.A.R.E bullshit) that teaches kids what certain drugs do, what the dangers are, how easyily it is to get addicted to certain substances etc ..
Final part: Crack down on the remaining illegal drugtrade (or whatever is left of it) HARD. There are still going to be people who don't have enough with the limited substance from the drugstores and these people are targets for illegal dealers. Now as the black market will have probably collapsed for the greatest part, it's alot easier to battle the rest of them. Most people wont bother with illegal dealers anyway since 90% (madeup figure) of users are recreational, not junkies.
Unfortunatly people are too retarded (OMG IT'S DRUGS IT'S GOING TO KILL MY KID! *chugs down a sixpack/bottle of wine*) so trying to do this would be political suicide. Hopefully we will achieve something similar to this in the future and a whole lot of misery will end.