共用方式為


如何:設定匿名對話安全性的目標服務 (Transact-SQL)

對於裝載起始服務之資料庫中存在遠端服務繫結的服務,SQL Server 會對任何與該服務的交談使用對話安全性。如果遠端服務繫結指定 ANONYMOUS = ON,則對話會使用匿名安全性。在此情況下,目標資料庫不需要包含起始服務的使用者。起始服務充當目標資料庫中的 public

若要設定匿名對話安全性的目標服務

  1. 建立不含登入的使用者。

  2. 為使用者建立憑證。

    [!附註]

    必須使用主要金鑰加密憑證。如需詳細資訊,請參閱<CREATE MASTER KEY (Transact-SQL)>。

  3. 將憑證備份至檔案。

    安全性注意事項安全性注意事項

    僅備份此使用者的憑證。不要備份或散發與憑證相關聯的私密金鑰。

  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 ;