ServerPermissionSet object represents a set of SQL Server permissions you want to grant, deny or revoke.
Server permissions are required when granting, denying, or revoking server-level permissions on an instance of SQL Server. The ServerPermission object is used to specify the set of permissions that apply to the Grant, Deny, and Revoke methods of the Server object. Also, server permissions can be added to the ServerPermissionSet object, which can also be used with the Deny, Revoke, and Grant methods.
ServerConnection conn = new ServerConnection(@"SQL_SERVER_INSTANCE", "LOGIN", "PASSWORD"); try { Server srv = new Server(conn); Database db = srv.Databases["AdventureWorks"]; foreach (ServerPermissionInfo serverPermInfo in srv.EnumServerPermissions("slimak")) { Console.WriteLine(serverPermInfo.ToString()); } Console.WriteLine("----------------"); ServerPermissionSet sps; sps = new ServerPermissionSet(ServerPermission.CreateAnyDatabase); srv.Grant(sps, "slimak"); foreach (ServerPermissionInfo serverPermInfo in srv.EnumServerPermissions("slimak")) { Console.WriteLine(serverPermInfo.ToString()); } Console.WriteLine("----------------"); sps = new ServerPermissionSet(ServerPermission.ViewAnyDatabase); srv.Deny(sps, "slimak"); foreach (ServerPermissionInfo serverPermInfo in srv.EnumServerPermissions("slimak")) { Console.WriteLine(serverPermInfo.ToString()); } Console.WriteLine("----------------"); sps = new ServerPermissionSet(ServerPermission.ViewAnyDatabase); srv.Revoke(sps, "slimak"); foreach (ServerPermissionInfo serverPermInfo in srv.EnumServerPermissions("slimak")) { Console.WriteLine(serverPermInfo.ToString()); } Console.WriteLine("----------------"); } catch (Exception err) { Console.WriteLine(err.Message); }
Hello…Content of your blog is awesome. I really liked it. Thanks for sharing this blog. Visit our website for Digital marketing course in pitampura.
ReplyDeleteHello, i to say it's really nice blog post. keep up. thanks for information.
ReplyDeletebollywood comedy
Digital Marketing Institute In Greater Noida
BEST IVF CENTER IN DELHI
Digital Marketing Course in Laxmi Nagar
Digital Marketing Institute in Delhi
Digital Marketing training in Preet Vihar
Online Digital Marketing Course in India
Digital Marketing Institute in Delhi
Digital Marketing Institute in Delhi
Best Digital Marketing
Great engaging information. Thank you for sharing. I found this post engaging and meaningful, which has added value in my understanding. Keep sharing good information.
ReplyDeletefreelance web developer
freelance web developer
php developers
Offshore Software Development
seo india
india seo service company