Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Grant View Server State to Role / Login / User using SMO

$
0
0

Hello All

I know that 

GRANT VIEW SERVER STATE TO User1 Or by writing GRANT VIEW SERVER STATE TO Login1

I can set this permision. But I want to set same kind of permission using SMO.

If possible then can we set it at Role level?

Or we only can set it at login or user level?

So can you guide me how to Grant VIew Server State using SMo to Role Or User Or Logins?

I also find that in SMO

server.Grant(new ServerPermissionSet(ServerPermission.ViewServerState), "Login1");

server.Grant(new ServerPermissionSet(ServerPermission.ViewServerState), "Login2");

So is this only way to do it Or there is anyother way to do it? 

Actualy I am using SMO object in generating Script. So I am not getting how this will be reflecting in script?

because By doing this I am just setting permission to particular name.

I am generating script of database. SO when user use this script to generate database at that time this permission should be set.

So for that purpose I want to do it at the time of creating script like somethink should be written in script using SMO for this permission.

Thanking you in advance..

Regards

Vipul



Viewing all articles
Browse latest Browse all 23857

Trending Articles



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