Skip to content

Instantly share code, notes, and snippets.

@ArcanaDev
Last active March 15, 2021 21:30
Show Gist options
  • Select an option

  • Save ArcanaDev/2843b60185d72e0bfda13a4242a6e25b to your computer and use it in GitHub Desktop.

Select an option

Save ArcanaDev/2843b60185d72e0bfda13a4242a6e25b to your computer and use it in GitHub Desktop.
Grant SQL Server database access to adTempus server #adtempus #sql #version4

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.

--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