Grant rights to Active Directory Group on SQL Server

Rather than adding each user from an AD security group, use that group to globally manage rights on SQL Server to all of those users, where appropriate, of course.

USE master;
GO
CREATE LOGIN [DOMAIN\Group Name] FROM WINDOWS;
GO
USE DatabaseName;
GO
CREATE USER [DOMAIN\Group Name] FROM LOGIN [DOMAIN\Group Name];
GO
-- assign the user a role
EXEC sp_addrolemember db_datareader, [DOMAIN\Group Name];
GO

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s