(Also keep in mind that, especially as of 2012, laws can vary by municipality; see below for more information.)
The intention of Dutch narcotics laws is to reduce harm: to preserve the public order and keep both users and non-users safe, which necessitates strict bans on certain narcotics - but less strict ones on others. One of the essential bases for these laws, set out in the Dutch "Opium Act", is the classification of narcotics into "Schedule I" (soft drugs) and "Schedule II" substances (hard drugs). What many visitors don't know is that all narcotics are in fact forbidden in the Netherlands - their production, import, export and, yes, sale and possession are prohibited under the letter of the law. However, Schedule I substances are subject to a policy of toleration under which violators are not prosecuted, provided that they adhere to certain strict limitations. In addition, there is a third class - namely, psychoactive plants - that isn't covered under the Opium Act (with the exclusion of psilocybin mushrooms, which were classified as a Schedule II substance in 2008).
The use of Schedule II substances - which include heroin, ecstasy, cocaine, opium, amphetamines, LSD and others - is strictly forbidden. The risks associated with these substances - both to public safety and to the users themselves - are deemed unacceptable. Despite its prohibition, ecstasy in particular remains prevalent at Dutch bars, clubs, festivals and events, with an estimated 40,000 ecstasy users in the country; however, ever stricter laws and penalties in recent years have put a dent in the production of and traffic in ecstasy. When it comes to Schedule II substances, the law is simple: just don't do it.
Schedule I substances - which include cannabis (marijuana and hash) and sedatives - are another story; while prohibition of these substances, within set limits, is not enforced, the lenience of the laws has bred some misinformation. It is a popular misconception, for example, that the production, trade and possession of cannabis is lawful in the Netherlands; in Amsterdam souvenir shops, it's not uncommon to find merchandise emblazoned with such phrases as, "It's legal here". As a matter of fact, it's not - but, under a special toleration policy, the authorities won't prosecute buyers and sellers who meet certain toleration criteria. Under this policy, if a cannabis coffeeshop does not sell more than five grams of cannabis per day to any one customer, sell to minors, advertise their wares, or otherwise create a public nuisance, their operation will be tolerated. Individuals may possess up to five grams of cannabis, a quantity deemed commensurate with "personal use". (Paradoxically, however, the cultivation or wholesale trade of cannabis is prohibited.) While this is the rule of thumb in the Netherlands, the laws vary by municipality, and there has been ample confusion since the appearance of the so-called wietpas ('weed pass'), proposed in 2012 and later retracted, and the revised laws that followed in its stead; for more information, see my article on Dutch cannabis policy.
Finally, psychoactive plants, which enjoy some measure of popularity in the Netherlands, are not covered under the Opium Act. This means that their production, sale and use is unrestricted (but it is advisable to exercise common sense in all these activities). Psilocybin mushrooms, however, have been prohibited under the Opium Act since 2008. For more information, see my article on psilocybin mushrooms in the Netherlands.