1

I have a database hosted on my machine that I want co-workers to be able to access and edit through a program I created.

My current connection string is:

Server=MyMachine;Database=MyDatabase;Integrated Security=True;

And to let another user access it I have to:

  1. Add a user under database security in SQL Server Management Studio
  2. Add a user under server security in SSMS
  3. Run the script:

    USE Database
     GRANT SELECT, INSERT, UPDATE, DELETE TO [Username]
    GO
    

How can I configure it so that everyone on my work network (or everyone whose windows username starts with "MyCompany\") can have these privileges by default? That way I don't have to manually add every new person.

asked Jun 23, 2015 at 15:44

1 Answer 1

8

You could create a domain group that you could use to create as login and user on your SQL Server and YourDatabase. After creating the domain group, you could do something like:

USE [master]
GO
CREATE LOGIN [DOMAIN\AllUsersForYourDatabase] FROM WINDOWS
GO
USE [YourDatabase]
GO
CREATE USER [DOMAIN\AllUsersForYourDatabase] 
FOR LOGIN [DOMAIN\AllUsersForYourDatabase] 
GO

You can then make the logins on your domain members of that group. All the logins will inherit the permissions granted to the group that gives them access. (You could include Domain Users in the group if you truly wanted everyone in the domain to have access.)

Of course, you need to grant the needed rights to the YourDatabase user [DOMAIN\AllUsersForYourDatabase] so that everybody in the group gets the same rights.

If you need some users to have additional rights, those can be individually granted. Or you can create another Group that would include only the users with the extra rights. The users will get the aggregate of all rights from all groups for that login.

answered Jun 23, 2015 at 15:52
3
  • Thanks a ton! This seems like a good direction. I'll try that and get back to you. Commented Jun 23, 2015 at 16:10
  • @crclayton Did this work for you? If so you can mark as answered. Commented Jul 29, 2015 at 19:24
  • Could you go into a little more detail on how to create a domain group? Commented Jul 29, 2015 at 21:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.