This SQL script grants access to the adTempus database for the machine where adTempus is running, allowing adTempus to connect to the database while running under the Local System account.
Last active
March 15, 2021 21:30
-
-
Save ArcanaDev/2843b60185d72e0bfda13a4242a6e25b to your computer and use it in GitHub Desktop.
Grant SQL Server database access to adTempus server #adtempus #sql #version4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --Replace "domain\machine" with the domain name and computer name of the adTempus server. Be sure to keep the "$" at the end of the name. | |
| -- For example, "mydomain\myservername$" | |
| --Replace "%adtdatabasename%" with the database name | |
| use [master] | |
| GO | |
| if not exists (select * from master.dbo.syslogins where loginname = N'%domain\machine%$') | |
| CREATE LOGIN [%domain\machine%$] FROM WINDOWS with DEFAULT_DATABASE=[%adtdatabasename%] | |
| go | |
| use [%adtdatabasename%] | |
| GO | |
| if not exists (select * from dbo.sysusers where name = N'%domain\machine%$' and uid < 16382) | |
| CREATE USER [%domain\machine%$] FOR LOGIN [%domain\machine%$] WITH DEFAULT_SCHEMA=[dbo] | |
| GO | |
| exec sp_addrolemember N'db_backupoperator', N'%domain\machine%$' | |
| GO | |
| exec sp_addrolemember N'db_datareader', N'%domain\machine%$' | |
| GO | |
| exec sp_addrolemember N'db_datawriter', N'%domain\machine%$' | |
| GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment