This morning I got a request to grant read-only database access to an AD Group. Here's how I did it:
Using SSMS, I ran these commands both in the master and the user database specified on the request. The reason why I added the user to the master database without any permissions is to allow login to succeed without defining a default database on the connection string.
Here's the code:
In the master database:
In the User database:
EXEC sp_addrolemember 'db_datareader', [AD Group Name]
No comments:
Post a Comment