Only a user with administrator privilege can impersonate
another user, and only an administrator with a Kinetica database account.
Any users who are mapped to Kinetica as administrators via external
authentication will need to ensure that a corresponding Kinetica
administrator account has been created for impersonation to succeed.Additionally, impersonation is only supported via ODBC/JDBC.
This command is only available through
KiSQL or database clients configured with
the Kinetica ODBC/JDBC driver.
EXECUTE AS Syntax
WITH NO REVERT option prevents the impersonated user from switching back
to the original user. This is useful in several cases, including:
- An administrator needs to run a script as a user with specific permissions, but doesn’t want the script to be able to revert back to administrator privileges during its execution.
- An application server connects to the database with its own credentials, but issues commands to the database on behalf of an application user. Again, there is a need to prevent the application user from reverting back to the application server’s database account and using those privileges to execute commands.
Example
To demonstrate the uses ofEXECUTE AS USER, the following commands can be
issued upon logging into the database as an administrator.
First, verify the current user is admin:
Show Current User Example
Current User Output
Switch User Example
Show Switched User
Switched User Output
Query Accessible Table as Switched User Example
Output
Query Inaccessible Table as Switched User Example
Output
Switch Back to Original User Example
Show Switched Back User
Switched Back User Output
WITH NO REVERT option:
Switch User without Reversion Example
Show Switched User
Switched User Output
Attempt to Switch Back Example
Output
Show Current User
Current User Output