Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

partial view server state via sp and execute as?

$
0
0

Hi all,

A user requested to be able to select from sys.dm_db_missing_index_details and sys.dm_db_index_usage_stats.
To select this two dynamic sp the user would require permission VIEW SERVER STATE.
Because this is a shared db environment I dont want to give view server state to user.
Instead I'd like to build a sp that delivers the required info without giving details of all other dbs.

What I did:

- created a new sql user 'u_someuser' and mapped user to access 'mydb'

- creted a usp
USE mydb
CREATE PROCEDURE usp_dm_db_missing_index_details_mydb
WITH EXECUTE AS 'u_someuser'
AS
SELECT * FROM sys.dm_db_missing_index_details WHERE database_id = 6

- granted execute right to user
USE mydb
GRANT EXECUTE ON usp_dm_db_missing_index_details_mydb TO u_someuser

- granted view server state to user
USE MASTER
GRANT VIEW SERVER STATE TO u_someuser

When I now execute usp (as u_someuser or even as sysadmin) I always get:
The user does not have permission to execute this action.

What do I miss out here ?
Any help is highly appreciated.
TIA
acki4711


 

Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>