2011-08-12 1 views
0

WCF의 가장에 관한 질문이 있습니다. 클라이언트 응용 프로그램에서 호출하는 WCF Windows 서비스의 DB에 연결하고 싶습니다. DB에 대한 연결은 서비스가 실행되는 계정을 사용하여 수행되어야합니다. 그러나 WCF 서비스에 대한 호출이 신뢰할 수있는 소스 (클라이언트 응용 프로그램의 사용자가 도메인의 Autenticated 사용자임을 확인)로부터 호출되었는지 확인하고 싶습니다.WCF Windows 서비스 DB 연결 및 가장 질문

내가 사용하도록 조언하는 종류의 보안은 무엇입니까?

내가 가장을 시도,하지만 난 Windows 서비스에서 DB에 연결을 시도하는이 오류를 얻을 :

System.Data.SqlClient.SqlException을 : 로그인 'NT AUTHORITY \ ANONYMOUS LOGON'사용자가 실패 .

구성 문자열은 다음과 같다 :

서버 =이 myServer; 초기 카탈로그 = MYDATABASE; 통합 보안 = 진정한

서비스의 WCF 구성은 다음과 같습니다

<system.serviceModel> 
<services> 
    <service name="MyNamespace.MyService" 
      behaviorConfiguration="TransfertServiceBehavior"> 
    <host> 
     <baseAddresses> 
     <add baseAddress="net.tcp://localhost:8095/MyNamespace.MyService"/> 
     </baseAddresses> 
    </host> 
    <endpoint address="" 
       binding="netTcpBinding" 
       bindingConfiguration="TransactionalBinding" 
       contract="myContract" /> 
    <endpoint address="mex" 
       binding="mexTcpBinding" 
       contract="IMetadataExchange" /> 
    </service> 
</services> 

<bindings> 
    <netTcpBinding> 
    <binding name="TransactionalBinding" 
      transferMode="Streamed" transactionFlow="true" maxReceivedMessageSize="1000000000"> 
     <readerQuotas maxDepth="10000" maxStringContentLength="1000000000" 
       maxArrayLength="1000000000" maxBytesPerRead="10000" maxNameTableCharCount="10000" /> 
     <security mode="Transport" /> 
    </binding> 

    </netTcpBinding> 
</bindings> 

<behaviors> 
    <serviceBehaviors> 
    <behavior name="TransfertServiceBehavior"> 
     <serviceMetadata httpGetEnabled="False"/> 
     <serviceDebug includeExceptionDetailInFaults="false"/> 
     <serviceAuthorization impersonateCallerForAllOperations="true" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 

클라이언트 응용 프로그램의 구성은 다음과 같습니다

<system.serviceModel> 
<bindings> 
    <netTcpBinding> 
    <binding name="NetTcpBinding_Client" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
     transactionFlow="true" transferMode="Streamed" transactionProtocol="OleTransactions" 
     hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="1000000000" 
     maxBufferSize="1000000000" maxConnections="10" maxReceivedMessageSize="65536"> 
     <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="1000000000" 
     maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
     <reliableSession ordered="true" inactivityTimeout="00:10:00" 
     enabled="false" /> 
     <security mode="Transport"> 
     <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
     <message clientCredentialType="Windows" /> 
     </security> 
    </binding> 
    </netTcpBinding> 
</bindings> 
<client> 

    <endpoint address="net.tcp://localhost:8095/MyNamespace.MyService" 
    binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Client" 
    contract="myContract" behaviorConfiguration="ImpersonationBehavior"> 
    <identity> 
     <userPrincipalName value="[email protected]" /> 
    </identity> 
    </endpoint> 
</client> 

<behaviors> 
    <endpointBehaviors> 
    <behavior name="ImpersonationBehavior"> 
     <clientCredentials> 
     <windows allowedImpersonationLevel="Impersonation" /> 
     </clientCredentials> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 

답변

2

WCF가 가장 할 경우 WCF 계정 서비스에 대해 Kerberos Constrained Delegation을 사용하도록 설정해야합니다 (Delegation and Impersonation with WCF 참조). Configure the WCF Service Identity Trusted for Constrained Delegation에서

자세한 설명 : 도메인 컨트롤러에서

  • 은 Microsoft 관리 콘솔 (MMC) Active Directory 사용자 및 컴퓨터 스냅인을 시작합니다.
  • MMC 스냅인의 왼쪽 창에서 컴퓨터 노드를 클릭합니다.
  • 오른쪽 창에서 WCF 서버 컴퓨터를 두 번 클릭하여 속성 대화 상자를 표시합니다.
  • WCF 서버의 속성 창의 위임 탭에서 컴퓨터의 위임을 위해 컴퓨터를 신뢰하지 않음을 선택하면 이 기본값으로 선택됩니다. 제한된 위임을 사용하려면 지정된 서비스에만 위임하려면이 컴퓨터 트러스트를 선택하십시오. 하단 창에서 서비스 또는 서비스에 액세스 할 수있는 정확한 위치를 지정합니다.
  • 아래 특정 서비스에 대한 위임을 위해이 컴퓨터를 신뢰합니다. 기본 옵션 만 사용 Kerberos 만 선택됨.
  • 추가 단추를 클릭하여 서비스 추가 대화 상자를 표시하십시오.
  • 사용자 또는 컴퓨터 단추를 클릭하십시오.
  • 사용자 또는 컴퓨터 선택 대화 상자에서 SQL 서버를 시스템 또는 네트워크 서비스로 실행하는 경우 데이터베이스 서버 컴퓨터의 이름을 입력하십시오.

    사용자 지정 도메인 계정을 사용하여 SQL Server를 실행하는 경우 대신 해당 계정 이름을 입력 한 다음 확인을 클릭하십시오. 선택한 사용자에 대해 구성된 모든 SPN 또는 컴퓨터 계정이 표시됩니다. SQL Server에 대한 액세스를 제한하려면 MSSQLSvc 서비스를 선택한 다음 확인을 클릭합니다.

+0

고마워요! 그것은 매우 도움이됩니다. 이것은 최고의 보안을 위해이를 수행하는 방법입니다. –

1

은 서비스 구성에서이 줄을 제거 :

<serviceAuthorization impersonateCallerForAllOperations="true" /> 

이 클라이언트의 구성 :

<behaviors> 
    <endpointBehaviors> 
    <behavior name="ImpersonationBehavior"> 
     <clientCredentials> 
     <windows allowedImpersonationLevel="Impersonation" /> 
     </clientCredentials> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 

명의 도용은 모든 작업이 위생적으로 수행됨을 의미합니다. 명의 도용 된 컨텍스트의 컨텍스트 = 서비스의 신원이 호출 한 사용자의 신원으로 대체됩니다. SQL 서버가 Windows 서비스가 실행중인 시스템에 로컬로 설치되어 있으면 데이터베이스 호출도 가장합니다.

서비스에서의 실행은 서비스 계정을 사용하지만 서비스는 각 호출 클라이언트를 인증하기 때문에 가장을 끄면 원하는 것을 정확하게 얻을 수 있습니다. Windows 통합 인증과 함께 전송 보안을 사용하는 netTcpBinding 구성에 의해 수행됩니다.

+0

내가 –

+0

는 그냥 명확하게하기 위해 ... 그것을 시도하지만, "무단 액세스"오류가 발생, 첫 번째 서비스 호출은 잘 작동합니다. 하지만이 서비스 자체가 두 번째 WCF 원격 서비스를 호출하고 두 번째 호출에서이 오류가 발생했습니다. –