This used to work on one of my old laptops, but ever since I started buying Dell laptops the screen wouldn’t lock when I closed the laptop lid.
To have your screen be locked when you close your lid, open a Termina and run gconf-editor
/apps
/gnome-power-manager
/lock
[x] blank_screen
Make sure that ‘Blank Screen’ is selected in Power Management Properties.