9

我有一个机器控制应用程序,其中我有一台客户端计算机和五个在机器子网上通信的服务器盒。没有域控制器。我想使用netTcpBinding来实现可靠性和事务支持。

当域控制器不存在时,是否可以通过此绑定使用用户名/密码身份验证?我不想使用证书,因为我不想管理 900 台不会连接到办公室 LAN 的计算机(150 台机器)的证书。

4

2 回答 2

11

是的,当然 - 但前提是您使用消息安全(而不是传输安全)。像这样定义您的绑定配置:

  <netTcpBinding>
    <binding name="UserNameSecurity">
      <security mode="Message">
        <message clientCredentialType="UserName"/>
      </security>
    </binding>
  </netTcpBinding>

然后在您的端点(在服务器和客户端)中引用该绑定配置:

 <endpoint address="....."
           binding="netTcpBinding"
           bindingConfiguration="UserNameSecurity"
           contract="IMyService" />

马克

更新:
啊,是的,在服务器端,您需要一个证书来向调用它的客户端验证服务,它还用于加密+签名消息。这仅在服务器上 - 客户端不需要安装任何东西。

配置:

<behaviors>
  <serviceBehavior>
    <behavior name="ServerInternet">
      <serviceCredentials>
        <serviceCertificate
           findValue="MyServiceCertificate"
           storeLocation="LocalMachine"
           storeName="My"
           x509FindType="FindBySubjectName" />
      </serviceCredentials>
    </behavior>
  </serviceBehavior>
</behaviors>
<services>
  <service name="MyServiceInternet"
           behaviorConfiguration="ServerInternet">
     ....
  </service>
</services>

确保将服务器的证书安装到服务器上的“本地计算机”文件夹中,位于您在配置中指定的“主题名称”下。

于 2009-08-03T15:31:29.447 回答
0

你可以先尝试一些东西。将 serviceNegotiationCredentials 设置为 true:

<message negotiateServiceCredential="true"/>

这将在您的客户端和您的服务之间创建一个安全的对话,而无需域控制器。

但是,如果没有任何域控制器,则客户端不信任您的服务,因此它将失败。

所以你应该设置服务的预期身份。您可以在服务的 WSDL 中找到它。默认情况下,如果您托管在 IIS 上,它似乎是:

<client>
    <endpoint>
        <identity>
            <servicePrincipalName value="host/NETWORKSERVICE"></servicePrincipalName>
        </identity>
    </endpoint>
</client>

我认为您不需要它,但也许您必须在服务端允许匿名登录:

<serviceBehaviors>
    <behavior>
        <serviceCredentials>
            <windowsAuthentication allowAnonymousLogons="true"/>
        </serviceCredentials>
    </behavior>
</serviceBehaviors>
于 2009-08-03T19:28:54.837 回答