[Zope] Obtaining the name of the authenticated user from within a product's source code

Stefan H. Holek stefan@epy.co.at
Thu, 20 Feb 2003 20:11:18 +0100


Igor!

You should not rely on AUTHENTICATED_USER.
>From DTML use _.SecurityGetUser().getUserName()
>From your Python product use

	from AccessControl import getSecurityManager

	user = getSecurityManager().getUser()
        name = user.getUserName()

HTH,
Stefan


--On Donnerstag, 20. Februar 2003 19:32 +0100 Igor Leturia <IGOR@emun.com> 
wrote:

>   I'm writing a product and I need to obtain the name of the
> authenticated user to use it in the source code of the product. I pass
> the REQUEST parameter to the product's method and I try to use
> REQUEST['AUTHENTICATED_USER'] inside it but it says that the property
> doesn't exist (which is true, because I've inspected the REQUEST object
> and it has all the 'normal' properties (HTTP_USER_AGENT,URL...) but it
> doesn't have that property). But if I try to access
> REQUEST['AUTHENTICATED_USER'] from within a DTMLMethod, it works. Why
> does this happen?

--
Those who write software only for pay should go hurt some other field.
/Erik Naggum/