Grant SQL Server database access to adTempus server

Language: SQL

View on GitHub to download or comment.

See the database model page for more information on querying the database.

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.

sample.sql
--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

Comments

View on GitHub to comment.