xo::ConnectionContext instproc eval_as_user (public)

 <instance of xo::ConnectionContext[i]> eval_as_user \
    [ -user_id user_id ] cmd

Defined in /var/www/openacs.org/packages/xotcl-core/tcl/context-procs.tcl

Run a command as the specified different user. Essentially, this method updates xo::cc and the ad_conn array array with the specified user, runs the command and resets the user to the previous value.

Switches:
-user_id (optional, integer)
switch temporarily to this user
Parameters:
cmd (required)
command to be exevuted

Testcases:
create_test_items
Source code:
#ns_log notice "RUN AS USER $user_id $cmd"
set result ""
set current_user_id [:get_user_id]
try  {
  :set_user_id $user_id
  :uplevel $cmd
} on ok {r} {
  set result $r
} finally {
  :set_user_id $current_user_id
}
return $result
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: