title: Is it possible to get "WITH EXECUTE AS " working under "dbo user/Administrator login" permissions (VIEW SERVER STATE needed)?
body: <p>The problem can be emulated this way:</p>
  
  <pre><code>DECLARE @C1 BIGINT,@C2 BIGINT;
  PRINT SUSER_NAME()+ ' '+ USER_NAME();
  SELECT @C1=transaction_id from sys.dm_tran_current_transaction (nolock)
  PRINT @C1
  EXECUTE AS USER = 'dbo';
  PRINT SUSER_NAME()+ ' '+ USER_NAME();
  SELECT @C2=transaction_id from sys.dm_tran_current_transaction (nolock)
  PRINT @C2
  REVERT;
  </code></pre>
  
  <p>Called from 'Administrator' login (db owner, linked to dbo user) returns:</p>
  
  <pre><code>Administrator dbo
  2209599
  Administrator dbo
  Msg 297, Level 16, State 1, Line 7
  The user does not have permission to perform this action.
  </code></pre>
  
  <p>The same user but different results. Why?</p>
  
  <p><strong>Details:</strong></p>
  
  <p>I have a SP that contains select from sys.dm_os_sys_info and therefore this SP's caller should have VIEW SERVER STATE permissions.</p>
  
  <p>I have modified SP header with "WITH EXECUTE AS OWNER". Owner is standard 'dbo' database user linked to 'Administrator' server login. Administrator is a member of sysadmin and have effective permission 'VIEW SERVER STATE', but execution of my modified procedure brings the 'The user does not have permission to perform this action' error... I see there logic since  DBO database user by itself doesn't have server permissions (even if Administrator login has). But what next?</p>
  
  <p>I have tried:</p>
  
  <ol>
  <li>GRANT VIEW SERVER STATE TO DBO - doesn't work because  of 'dbo is
  not a user-defined server role' error.  </li>
  <li>Create new user  'ServerStateViewer' linked to 'Administrator' - doesn't work becuase of 'the login already has an account under a different user name' (as I understand it - dbo user exits in the dabatabse) </li>
  <li>Create new user  'ServerStateViewer' not linked to any login - doesn't work because I can't to add any server permissions to this user.</li>
  <li>WITH EXECUTE AS 'Administrator' -   doesn't work because of 'Administrator is not a database user'  error.</li>
  </ol>
  
  <p>So it seems I'm forced to create new server login. I am interesting, may be there are still other ways to get WITH EXECUTE AS working under dbo user / Administrator login permissions? </p>