如何将目标服务配置为使用完全对话安全模式 (Transact-SQL)

如果承载发起服务的数据库中存在某服务的远程服务绑定,那么,SQL Server对与该服务的任何会话均使用对话安全模式。如果承载目标服务的数据库包含与创建该对话的用户相对应的用户,则该对话使用完全安全模式。

若要确保目标服务使用对话安全模式,请创建登录时要用的起始服务用户。为每个起始服务创建一个用户,并为该起始用户安装证书。请注意,目标服务不使用远程服务绑定。

将目标服务配置为使用完全对话安全模式

  1. 创建一个不含登录名的用户。

  2. 为该用户创建一个证书。

    ms166072.note(zh-cn,SQL.90).gif注意:
    证书必须使用主密钥进行加密。有关详细信息,请参阅 CREATE MASTER KEY (Transact-SQL)
  3. 使该用户成为目标服务的所有者。

  4. 将证书备份到文件。

    ms166072.security(zh-cn,SQL.90).gif安全说明:
    只需备份此用户的证书。请勿备份或分发与该证书关联的私钥。
  5. 为目标服务用户授予权限,使其能够从目标服务所使用的队列中接收消息。

  6. 为远程数据库的数据库管理员提供证书和发起服务的名称。

    ms166072.note(zh-cn,SQL.90).gif注意:
    为使 SQL Server 使用完全对话安全模式,远程数据库中必须安装该证书,且该证书的用户必须是目标服务的远程服务绑定中指定的用户。
  7. 从可信来源为远程数据库中的用户获取证书。这通常会涉及到使用加密电子邮件发送证书或通过软盘等物理媒体传输证书。

    ms166072.security(zh-cn,SQL.90).gif安全说明:
    只能安装来自可信来源的证书。
  8. 创建一个不含登录名的用户。

  9. 为起始服务安装证书。上一步中创建的用户拥有该证书。

  10. 为起始服务证书创建一个用户,该用户创建后不登录。

  11. 为起始用户授予向目标服务发送消息的权限。

示例

USE AdventureWorks ;
GO

--------------------------------------------------------------------
-- The first part of the script configures security for the local user.
-- The script creates a user in this database, creates a certificate
-- for the user, writes the certificate to the file system, and
-- grants permissions to the user. Since this service is a target
-- service, no remote service binding is necessary.


-- Create a user without a login. For convenience,
-- the name of the user is based on the name of the
-- the remote service.

CREATE USER [SupplierOrdersUser]
    WITHOUT LOGIN;
GO

-- Create a certificate for the initiating service
-- to use to send messages to the target service.

CREATE CERTIFICATE [SupplierOrdersCertificate]
    AUTHORIZATION [SupplierOrdersUser]
    WITH SUBJECT = 'Certificate for the SupplierOrders service user.';
GO

-- Dump the certificate. Provide the certificate file
-- to the administrator for the database that hosts
-- the other service.

BACKUP CERTIFICATE [SupplierOrdersCertificate]
   TO FILE = 'C:\Certificates\SupplierOrders.cer';
GO
-- Make this user the owner of the target service.

ALTER AUTHORIZATION ON SERVICE::SupplierOrders TO [SupplierOrdersUser];
GO

-- Grant receive on the orders queue to the local user.

GRANT RECEIVE ON SupplierOrdersQueue
    TO [SupplierOrdersUser];
GO

---------------------------------------------------------------
-- The second part of the script configures security in this
-- database for the remote service. This consists of creating
-- a user in this database, loading the certificate for the remote
-- service, and granting permissions for the user.


-- Create a user without a login.

CREATE USER [OrderPartsUser]
    WITHOUT LOGIN;
GO

-- Install a certificate for the initiating user.
-- The certificate is provided by the owner of the
-- initiating service.

CREATE CERTIFICATE [OrderPartsCertificate]
    AUTHORIZATION [OrderPartsUser]
    FROM FILE='C:\Certificates\OrderParts.cer';
GO

-- Grant send on the target service to the user for the
-- initating service.

GRANT SEND ON SERVICE::[SupplierOrders]
    TO [OrderPartsUser];
GO

请参阅

任务

如何将起始服务配置为使用完全对话安全模式 (Transact-SQL)
如何为本地服务配置权限 (Transact-SQL)

其他资源

CREATE CERTIFICATE (Transact-SQL)
CREATE USER (Transact-SQL)
CREATE REMOTE SERVICE BINDING (Transact-SQL)
CREATE MASTER KEY (Transact-SQL)

帮助和信息

获取 SQL Server 2005 帮助