Couple of sources of info here:
The Dutch law on cannabis is summed up by the word 'gedogen' which means "allowing less..."
Basically, if you are caught in possession of less than 5 grams of either marihuana or hashish you will not be prosecuted.
The drugs, however, will be confiscated.
If you possess more than 5 grams, you stand a "fair chance" of prosecution.
Coffee-shops are licensed to sell cannabis, but they cannot sell to under 18's, cannot advertise, and cannot stock more than 500 grams of soft drugs.
Taken from:
http://www.seethru.co.uk/zine/guides/amsterdam/can
nabis_laws.htm
And:
International law means that the Netherlands cannot make cannabis legal and so this complicates the situation. Cannabis consumption is therefore viewed as decriminilised rather than legalised as technically it is illegal in Holland. Personal possession of a small quantity (under 30g) of cannabis is allowed.
Coffeeshops are allowed to sell small amounts of cannabis and are strictly regulated and taxed. Coffeeshops must not sell to anyone under the age of 18, they must not sell more than 5g to any customer and they must not hold more than 500g on the premises. Also hard drugs are strictly forbidden.
Taken from:
http://www.eatdrinketc.com/amsterdam/source/site_c
ontent_subcontent.asp?content_id=29&channel_id=11
I think that the bottom line is that is is illegal but tollerated in moderation.