|
1 | 1 | --- |
2 | | -title: "How to: Configure Target Services for Full Dialog Security (Transact-SQL)" |
| 2 | +title: "How To: Configure Target Services for Full Dialog Security (Transact-SQL)" |
3 | 3 | description: "SQL Server uses dialog security for any conversation to a service for which a remote service binding exists in the database that hosts the initiating service." |
4 | 4 | author: rwestMSFT |
5 | 5 | ms.author: randolphwest |
6 | 6 | ms.reviewer: mikeray, maghan |
7 | | -ms.date: "03/30/2022" |
| 7 | +ms.date: 09/02/2025 |
8 | 8 | ms.service: sql |
9 | 9 | ms.subservice: configuration |
10 | 10 | ms.topic: how-to |
11 | 11 | --- |
12 | 12 |
|
13 | | -# How to: Configure Target Services for Full Dialog Security (Transact-SQL) |
| 13 | +# How to: Configure target services for full dialog security (Transact-SQL) |
14 | 14 |
|
15 | 15 | [!INCLUDE [sql-asdbmi](../../includes/applies-to-version/sql-asdbmi.md)] |
16 | 16 |
|
17 | 17 | SQL Server uses dialog security for any conversation to a service for which a remote service binding exists in the database that hosts the initiating service. When the database that hosts the target service contains a user that corresponds to the user that created the dialog, then the dialog uses full security. |
18 | 18 |
|
19 | | -To make sure that a target service uses dialog security, create a user for the initiating service to log in as. For each initiating service, create a user and install the certificate for the initiating user. Notice that a target service does not use a remote service binding. |
| 19 | +To make sure that a target service uses dialog security, create a user the initiating service can use to log in. For each initiating service, create a user and install the certificate for the initiating user. A target service doesn't use a remote service binding. |
20 | 20 |
|
21 | | -## To configure a target service for full dialog security |
| 21 | +## Configure a target service for full dialog security |
22 | 22 |
|
23 | 23 | 1. Create a user without a login. |
24 | 24 |
|
25 | | -2. Create a certificate for the user. |
| 25 | +1. Create a certificate for the user. |
26 | 26 |
|
27 | | - > [!NOTE] |
28 | | - > The certificate must be encrypted with the master key. For more information, see [CREATE MASTER KEY (Transact-SQL)](../../t-sql/statements/create-master-key-transact-sql.md). |
| 27 | + > [!NOTE] |
| 28 | + > The certificate must be encrypted with the master key. For more information, see [CREATE MASTER KEY](../../t-sql/statements/create-master-key-transact-sql.md). |
29 | 29 |
|
30 | | -3. Make that user the owner of the target service. |
| 30 | +1. Make that user the owner of the target service. |
31 | 31 |
|
32 | | -4. Back up the certificate to a file. |
| 32 | +1. Back up the certificate to a file. |
33 | 33 |
|
34 | | - > [!NOTE] |
35 | | - > Only back up the certificate for this user. Do not back up or distribute the private key associated with the certificate. |
| 34 | + > [!NOTE] |
| 35 | + > Only back up the certificate for this user. Don't back up or distribute the private key associated with the certificate. |
36 | 36 |
|
37 | | -5. Grant permission for the target service user to receive messages from the queue that the target service uses. |
| 37 | +1. Grant permission for the target service user to receive messages from the queue that the target service uses. |
38 | 38 |
|
39 | | -6. Provide the certificate and the name of the initiating service to the database administrator for the remote database. |
| 39 | +1. Provide the certificate and the name of the initiating service to the database administrator for the remote database. |
40 | 40 |
|
41 | | - > [!NOTE] |
| 41 | + > [!NOTE] |
42 | 42 | > For SQL Server to use full dialog security, the certificate must be installed in the remote database, and the user for the certificate must be the user specified in the remote service binding for the target service. |
43 | 43 |
|
44 | | -7. Obtain a certificate for a user in the remote database from a trusted source. Typically, this involves sending the certificate using encrypted e-mail or transferring the certificate on physical media such as a floppy disk. |
| 44 | +1. Obtain a certificate for a user in the remote database from a trusted source. Typically, this involves sending the certificate using encrypted email or transferring the certificate on physical media such as a floppy disk. |
45 | 45 |
|
46 | | - > [!NOTE] |
| 46 | + > [!NOTE] |
47 | 47 | > Only install certificates from trusted sources. |
48 | 48 |
|
49 | | -8. Create a user without a login. |
| 49 | +1. Create a user without a login. |
50 | 50 |
|
51 | | -9. Install the certificate for the initiating service. The user created in the previous step owns the certificate. |
| 51 | +1. Install the certificate for the initiating service. The user created in the previous step owns the certificate. |
52 | 52 |
|
53 | | -10. Create a user without a login for the initiating service certificate. |
| 53 | +1. Create a user without a login for the initiating service certificate. |
54 | 54 |
|
55 | | -11. Grant permission for the initiating user to send messages to the target service. |
| 55 | +1. Grant permission for the initiating user to send messages to the target service. |
56 | 56 |
|
57 | | -## Example |
| 57 | +## Examples |
58 | 58 |
|
59 | 59 | [!INCLUDE [SQL Server Service Broker AdventureWorks2008R2](../../includes/service-broker-adventureworks-2008-r2.md)] |
60 | 60 |
|
61 | 61 | ```sql |
62 | | - USE AdventureWorks2008R2 ; |
63 | | - GO |
64 | | - |
65 | | - -------------------------------------------------------------------- |
66 | | - -- The first part of the script configures security for the local user. |
67 | | - -- The script creates a user in this database, creates a certificate |
68 | | - -- for the user, writes the certificate to the file system, and |
69 | | - -- grants permissions to the user. Since this service is a target |
70 | | - -- service, no remote service binding is necessary. |
71 | | - |
72 | | - |
73 | | - -- Create a user without a login. For convenience, |
74 | | - -- the name of the user is based on the name of the |
75 | | - -- the remote service. |
76 | | - |
77 | | - CREATE USER [SupplierOrdersUser] |
78 | | - WITHOUT LOGIN; |
79 | | - GO |
80 | | - |
81 | | - -- Create a certificate for the initiating service |
82 | | - -- to use to send messages to the target service. |
83 | | - |
84 | | - CREATE CERTIFICATE [SupplierOrdersCertificate] |
85 | | - AUTHORIZATION [SupplierOrdersUser] |
86 | | - WITH SUBJECT = 'Certificate for the SupplierOrders service user.'; |
87 | | - GO |
88 | | - |
89 | | - -- Dump the certificate. Provide the certificate file |
90 | | - -- to the administrator for the database that hosts |
91 | | - -- the other service. |
92 | | - |
93 | | - BACKUP CERTIFICATE [SupplierOrdersCertificate] |
94 | | - TO FILE = 'C:\Certificates\SupplierOrders.cer'; |
95 | | - GO |
96 | | - -- Make this user the owner of the target service. |
97 | | - |
98 | | - ALTER AUTHORIZATION ON SERVICE::SupplierOrders TO [SupplierOrdersUser]; |
99 | | - GO |
100 | | - |
101 | | - -- Grant receive on the orders queue to the local user. |
102 | | - |
103 | | - GRANT RECEIVE ON SupplierOrdersQueue |
104 | | - TO [SupplierOrdersUser]; |
105 | | - GO |
106 | | - |
107 | | - --------------------------------------------------------------- |
108 | | - -- The second part of the script configures security in this |
109 | | - -- database for the remote service. This consists of creating |
110 | | - -- a user in this database, loading the certificate for the remote |
111 | | - -- service, and granting permissions for the user. |
112 | | - |
113 | | - |
114 | | - -- Create a user without a login. |
115 | | - |
116 | | - CREATE USER [OrderPartsUser] |
117 | | - WITHOUT LOGIN; |
118 | | - GO |
119 | | - |
120 | | - -- Install a certificate for the initiating user. |
121 | | - -- The certificate is provided by the owner of the |
122 | | - -- initiating service. |
123 | | - |
124 | | - CREATE CERTIFICATE [OrderPartsCertificate] |
125 | | - AUTHORIZATION [OrderPartsUser] |
126 | | - FROM FILE='C:\Certificates\OrderParts.cer'; |
127 | | - GO |
128 | | - |
129 | | - -- Grant send on the target service to the user for the |
130 | | - -- initiating service. |
131 | | - |
132 | | - GRANT SEND ON SERVICE::[SupplierOrders] |
133 | | - TO [OrderPartsUser]; |
134 | | - GO |
| 62 | +USE AdventureWorks2008R2; |
| 63 | +GO |
| 64 | + |
| 65 | +-------------------------------------------------------------------- |
| 66 | +-- The first part of the script configures security for the local user. |
| 67 | +-- The script creates a user in this database, creates a certificate |
| 68 | +-- for the user, writes the certificate to the file system, and |
| 69 | +-- grants permissions to the user. Since this service is a target |
| 70 | +-- service, no remote service binding is necessary. |
| 71 | + |
| 72 | +-- Create a user without a login. For convenience, |
| 73 | +-- the name of the user is based on the name of the |
| 74 | +-- the remote service. |
| 75 | +CREATE USER [SupplierOrdersUser] |
| 76 | + WITHOUT LOGIN; |
| 77 | +GO |
| 78 | + |
| 79 | +-- Create a certificate for the initiating service |
| 80 | +-- to use to send messages to the target service. |
| 81 | +CREATE CERTIFICATE [SupplierOrdersCertificate] |
| 82 | + AUTHORIZATION [SupplierOrdersUser] |
| 83 | + WITH SUBJECT = 'Certificate for the SupplierOrders service user.'; |
| 84 | +GO |
| 85 | + |
| 86 | +-- Dump the certificate. Provide the certificate file |
| 87 | +-- to the administrator for the database that hosts |
| 88 | +-- the other service. |
| 89 | +BACKUP CERTIFICATE [SupplierOrdersCertificate] |
| 90 | + TO FILE = 'C:\Certificates\SupplierOrders.cer'; |
| 91 | +GO |
| 92 | + |
| 93 | +-- Make this user the owner of the target service. |
| 94 | +ALTER AUTHORIZATION ON SERVICE::SupplierOrders |
| 95 | + TO [SupplierOrdersUser]; |
| 96 | +GO |
| 97 | + |
| 98 | +-- Grant receive on the orders queue to the local user. |
| 99 | +GRANT RECEIVE ON SupplierOrdersQueue |
| 100 | + TO [SupplierOrdersUser]; |
| 101 | +GO |
| 102 | + |
| 103 | +--------------------------------------------------------------- |
| 104 | +-- The second part of the script configures security in this |
| 105 | +-- database for the remote service. This consists of creating |
| 106 | +-- a user in this database, loading the certificate for the remote |
| 107 | +-- service, and granting permissions for the user. |
| 108 | + |
| 109 | +-- Create a user without a login. |
| 110 | +CREATE USER [OrderPartsUser] |
| 111 | + WITHOUT LOGIN; |
| 112 | +GO |
| 113 | + |
| 114 | +-- Install a certificate for the initiating user. |
| 115 | +-- The certificate is provided by the owner of the |
| 116 | +-- initiating service. |
| 117 | +CREATE CERTIFICATE [OrderPartsCertificate] |
| 118 | + AUTHORIZATION [OrderPartsUser] |
| 119 | + FROM FILE = 'C:\Certificates\OrderParts.cer'; |
| 120 | +GO |
| 121 | + |
| 122 | +-- Grant send on the target service to the user for the |
| 123 | +-- initiating service. |
| 124 | +GRANT SEND ON SERVICE::[SupplierOrders] |
| 125 | + TO [OrderPartsUser]; |
| 126 | +GO |
135 | 127 | ``` |
136 | 128 |
|
137 | | -## See also |
| 129 | +## Related content |
138 | 130 |
|
139 | | -- [How to: Configure Initiating Services for Full Dialog Security (Transact-SQL)](how-to-configure-initiating-services-for-full-dialog-security-transact-sql.md) |
140 | | -- [How to: Configure Permissions for a Local Service (Transact-SQL)](how-to-configure-permissions-for-a-local-service-transact-sql.md) |
| 131 | +- [How to: Configure initiating services for full dialog security (Transact-SQL)](how-to-configure-initiating-services-for-full-dialog-security-transact-sql.md) |
| 132 | +- [How to: Configure permissions for a local service (Transact-SQL)](how-to-configure-permissions-for-a-local-service-transact-sql.md) |
141 | 133 | - [CREATE CERTIFICATE (Transact-SQL)](../../t-sql/statements/create-certificate-transact-sql.md) |
142 | 134 | - [CREATE USER (Transact-SQL)](../../t-sql/statements/create-user-transact-sql.md) |
143 | 135 | - [CREATE REMOTE SERVICE BINDING (Transact-SQL)](../../t-sql/statements/create-remote-service-binding-transact-sql.md) |
|
0 commit comments