forked from SQL-FineBuild/v3.5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSet-StartJobProxy.sql
More file actions
40 lines (38 loc) · 1.11 KB
/
Set-StartJobProxy.sql
File metadata and controls
40 lines (38 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
USE msdb;
GO
CREATE CERTIFICATE StartJobProxy
ENCRYPTION BY PASSWORD = 'strsaPwd''
WITH
SUBJECT = 'StartJobProxy'
,START_DATE='2000/01/01'
,EXPIRY_DATE='2999/12/31';
GO
BACKUP CERTIFICATE [StartJobProxy]
TO FILE='\\share\SystemDataBackup\server\StartJobProxy.cer'
WITH PRIVATE KEY (
FILE = '\\share\SystemDataBackup\server\StartJobProxy.pvk',
ENCRYPTION BY PASSWORD = 'strsaPwd',
DECRYPTION BY PASSWORD = 'strsaPwd');
GO
CREATE USER [StartJobProxy]
FROM CERTIFICATE [StartJobProxy];
GO
GRANT AUTHENTICATE TO [StartJobProxy];
GRANT EXECUTE ON msdb.dbo.sp_start_job TO [StartJobProxy];
GO
USE [UserDB];
GO
CREATE CERTIFICATE [StartJobProxy]
FROM FILE='\\share\SystemDataBackup\server\StartJobProxy.cer'
WITH PRIVATE KEY (
FILE = '\\share\SystemDataBackup\server\StartJobProxy.pvk',
ENCRYPTION BY PASSWORD = 'strsaPwd',
DECRYPTION BY PASSWORD = 'strsaPwd');
GO
ADD SIGNATURE TO dbo.[spJobStartProc]
BY CERTIFICATE [StartJobProxy]
WITH PASSWORD = 'strsaPwd';
GO
EXEC dbo.spJobStartProc;
GO
-- spJobStartProc must be created using WITH EXECUTE AS [Job Owner]