Logout button in a portlet

Is it possible to logout using a button/link command in a portlet? If it is how do I go about it?
If it’s not, is it possible to remove the other functionality available to users in the top panel such as “Administration”.

Ok so I found the way to include the Portlet/wm_loginorout in my own portlet. But now when I click on the link provided it takes me back to the http://hostname:8585/ with an error of
“[POP.007.0009] You are not authorized to view this resource.”

Any ideas?