Verify the Current Impersonation Status of a User

A successful impersonation remains in effect until it is manually terminated or the session is terminated.

To verify the current status of an impersonation, execute this command on a machine on which the SETUSER command was issued:

SELECT CURRENT USER

The name of the user the machine recognizes as the currently logged in user appears. If it is the expected user for the machine, no impersonation is active on the machine. If an unexpected user name appears, it represents the user currently being impersonated on the machine.

Example

On a connection where Joe is logged in, execute:
> select current user
> go
current user 
-------------------------------------------------------------------------------------------------------------------------------- 
Joe 

(1 row affected) 

>setuser mary
>go
>select current user 
> go 
current user 
-------------------------------------------------------------------------------------------------------------------------------- 
Mary