3

同じマシンに 2 つの WCF サービスがあります。1 つはパブリッシャーで、もう 1 つはリスナーです。

パブリッシャーは、エンドポイントに基づいてプロキシを動的に作成しています。次のようなコードでプロキシを構成しています。

            WSHttpBinding binding = new WSHttpBinding(SecurityMode.Message, true);
            binding.Security.Message.NegotiateServiceCredential = true;
            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
            binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
            binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
            binding.Security.Message.EstablishSecurityContext = true;
            binding.ReliableSession.Enabled = true;
            binding.TransactionFlow = true;
            return binding;

その後...

            Binding binding = GetBindingFromAddress(address);

            ChannelFactory<T> factory = new ChannelFactory<T>(binding);
            factory.Credentials.UserName.UserName = "an account on the machine";
            factory.Credentials.UserName.Password = "a password for that account";

            T proxy = factory.CreateChannel(new EndpointAddress(address));

電話をかけようとすると、上記のエラーが表示されます。これが私のリスナー設定ファイルです:

   <service behaviorConfiguration="MEX Enabled" name="InvoiceSubscriber">
<endpoint binding="wsHttpBinding"
          bindingConfiguration="ReliableTransactionalHTTP"
          contract="AtlanticBT.SubscriptionService.Contracts.v1.IAtlanticEvents">
 <identity>
  <dns value="localhost" />
 </identity>
</endpoint>

        <bindings>
        <wsHttpBinding>
            <binding name="ReliableTransactionalHTTP" transactionFlow="true">
                <reliableSession enabled="true"/>
      <security mode="Message">
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
        <message clientCredentialType="Windows" negotiateServiceCredential="true" 
                 algorithmSuite="Default" establishSecurityContext="true"/>
      </security>
            </binding>
  </wsHttpBinding>
    </bindings>

サービスをホストするディレクトリのすべての ACL を確認しましたが、それらは正しいようです。IIS セキュリティは、匿名アクセスと Windows 認証に設定されています。

コードで資格情報を明示的に設定している場合、リスナーが認証できないのはなぜですか?

4

1 に答える 1

16

まず、このメッセージは通常、マシンが同じドメインにないため、Windows セキュリティを使用して通信できないことを意味します。2 つのサーバーは同じドメインにありますか?

次に、Windows セキュリティを使用するようにエンドポイントを構成しました。メッセージ レベルだけでなく、トランスポート レベルでも Windows セキュリティを使用している。どちらもやり過ぎのように思えます。おそらく、トランスポートを実行したいだけです。

3 番目に、構成したものはすべて「Windows 認証を使用したい」と言っていますが、ClientCredentials の UsernameClientCredentials プロパティを設定しています。これらのプロパティは、Windows ではなく、ユーザー名トークン セキュリティにのみ使用されます。Windows セキュリティは、現在のスレッドの ID を取得して転送します。

あなたの意図が Windows セキュリティを使用することであったと仮定すると、次のいずれかを行う必要があります。

  1. サブスクライバーとの通信に使用する単一の Windows ID でパブリッシャー プロセスを実行します。
  2. パブリッシャー プロセス内で偽装を使用して、各呼び出しのセキュリティ コンテキストを変更します (詳細については、 WindowsIdentity.Impersonateを参照してください) 。

現在、ユーザー名/パスワードのプロパティが無視されているため、ユーザー名/パスワードのプロパティを設定することで #2 を行っていると思っていても、技術的には #1 を行っています。

最後に、さまざまな種類の Windows 認証シナリオに合わせてバインドをセットアップする方法についての優れたドキュメントを次に示します。


これ以上、あなたからの情報がなければ、他に何を提供できるかわかりません。質問を修正して、より多くの情報を提供したり、私の質問のいくつかに答えたりする場合は、回答を喜んで修正して、より役立つようにします。

于 2009-10-29T01:34:59.103 に答える