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:
- Add a user under database security in SQL Server Management Studio
- Add a user under server security in SSMS
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.
1 Answer 1
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.
-
Thanks a ton! This seems like a good direction. I'll try that and get back to you.Charles Clayton– Charles Clayton2015年06月23日 16:10:44 +00:00Commented Jun 23, 2015 at 16:10
-
@crclayton Did this work for you? If so you can mark as answered.RLF– RLF2015年07月29日 19:24:56 +00:00Commented Jul 29, 2015 at 19:24
-
Could you go into a little more detail on how to create a domain group?Charles Clayton– Charles Clayton2015年07月29日 21:10:00 +00:00Commented Jul 29, 2015 at 21:10
Explore related questions
See similar questions with these tags.