I know that I can redirect the stdout to an environment variable, e.g.
retcode=$(/usr/bin/osascript -e 'do shell script ... with administrator privileges')
but how do redirect the stderr output to an environment variable, too (in this example to detect a user cancelling the admin credentials dialog)?