Compartilhar via


Como configurar serviços iniciais para segurança anônima de diálogo (Transact-SQL)

O SQL Server usa segurança de diálogo em qualquer conversação com um serviço para o qual exista uma associação de serviço remoto. Se o banco de dados que hospeda o serviço de destino não contiver um usuário que corresponda ao que criou o diálogo, o diálogo usará segurança anônima.

Observação sobre segurançaObservação sobre segurança

Instale somente certificados de origens confiáveis.

  1. Obtenha um certificado para um usuário no banco de dados remoto de uma fonte confiável.

  2. Crie um usuário sem um logon.

  3. Instale o certificado para o serviço remoto. O usuário criado na etapa 3 possui o certificado. Por padrão, o certificado estará ativo para BEGIN DIALOG.

  4. Crie uma associação de serviço remoto que especifique o usuário e o serviço de destino. Para a segurança anônima de diálogo, a associação de serviço remoto especificará ANONYMOUS = ON.

Exemplo

Este exemplo configura uma segurança anônima de diálogo para conversações entre o serviço nomeado OrderParts na instância atual e o serviço nomeado SupplierOrders na instância remota.

USE AdventureWorks ;
GO

-- Given a certificate for a remote user for the remote service
-- SupplierOrders, create a remote service binding for
-- the service.  The remote user will be granted permission
-- to send messages to the local service OrderParts. 
-- This example assumes that the certificate for the service 
-- is saved in the file'C:\Certificates\SupplierOrders.cer' and that
-- the initiating service already exists.


-- Create a user without a login.

CREATE USER [SupplierOrdersUser]
    WITHOUT LOGIN ;
GO

-- Install a certificate for the owner of the service
-- in the remote database. The certificate is
-- provided by the owner of the remote service. The
-- user for the remote service owns the certificate.

CREATE CERTIFICATE [SupplierOrdersCertificate]
    AUTHORIZATION [SupplierOrdersUser]
    FROM FILE='C:\Certificates\SupplierOrders.cer' ;
GO

-- Create the remote service binding. Notice
-- that the user specified in the binding
-- does not own the binding itself.

-- Creating this binding specifies that messages from
-- this database are secured using the certificate for
-- the [SupplierOrdersUser] user.

-- Since anonymous is ON, the credentials for the user
-- that begins the conversation are not used for the
-- conversation.

CREATE REMOTE SERVICE BINDING [SupplierOrdersBinding]
    TO SERVICE 'SupplierOrders'
    WITH USER = [SupplierOrdersUser],
         ANONYMOUS = ON ;
GO