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

如果承载发起服务的数据库中存在某服务的远程服务绑定,那么,SQL Server对与该服务的任何会话均使用对话安全模式。如果远程服务绑定指定 ANONYMOUS = ON,则对话使用匿名安全模式。在这种情况下,目标数据库无需包含该起始服务的用户。起始服务在目标数据库中作为 public 来运行。

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

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

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

    ms166108.note(zh-cn,SQL.90).gif注意:
    证书必须使用主密钥进行加密。有关详细信息,请参阅 CREATE MASTER KEY (Transact-SQL)
  3. 将证书备份到文件。

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

  5. 授予 PUBLIC 权限,以向目标服务发送消息。

  6. 将目标服务的证书和名称提供给远程数据库的数据库管理员。

示例

USE AdventureWorks ;
GO

--------------------------------------------------------------------
-- This script configures security for a local user in the database.
-- 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

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

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

GRANT RECEIVE ON SupplierOrdersQueue
    TO [SupplierOrdersUser];
GO

-- Grant send on the service to public.

GRANT SEND ON SERVICE::[SupplierOrders] TO public ;

请参阅

任务

如何为本地服务配置权限 (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 帮助