WCFのなりすましに関する質問があります。私は、クライアントアプリケーションによって呼び出されるWCF Windowsサービス上のDBに接続したいと思います。 DBへの接続は、サービスを実行するアカウントを使用して行う必要があります。しかし、WCFサービスへの呼び出しが信頼できるソースから行われたことを検証したいと思います(クライアントアプリケーションのユーザーがドメインの自認ユーザーであることを確認してください)。WCF WindowsサービスDBの接続となりすましに関する質問
私が使用を勧める種類のセキュリティは何ですか?
私が偽装を試みたが、WindowsサービスからDBに接続しようとしたとき、私はこのエラーを取得:
System.Data.SqlClient.SqlException:ユーザーのログインに失敗しました「NT AUTHORITY \ ANONYMOUS LOGON」 。
構成文字列は、このようなものです:
サーバー= myServerという;初期カタログ= MYDATABASE; = Trueの
統合セキュリティサービスの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>
ありがとう!それは非常に役に立ちます。これは私が推測する最高のセキュリティのためにそれを行う方法です。 –