Rub*_*aus 3 wcf identity wcf-security
我和我正在开发的团队有一个相当大的应用程序,它包含许多基于WCF NetTCP的服务.此系统将在其下运行的Windows服务不是本地帐户,而是标准域用户(在托管服务的服务器上具有管理员权限).在测试连接的过程中,我遇到了SSPI调用失败的问题.基于几个小时的研究,这导致我失去了我的客户端配置中的以下行:
<identity>
<userPrincipalName value="MACHINE\user" />
</identity>
Run Code Online (Sandbox Code Playgroud)
使用它的问题是我不使用VS或svcutil为此服务生成客户端/代理 - 正在使用的代理完全用代码编写,并且它们继承System.ServiceModel.ClientBase.我认为选择此选项的原因是我们可以使用完全相同的DataMember对象,这些对象通过栅栏两侧的服务 - 第三方组不需要连接到我们的服务,所以这不是问题.
当我没有在标准system.serviceModel配置部分中指定端点时,有没有人知道我在客户端(代码或通过配置)中设置userPrincipalName的方法?
以下是我的客户端web.config的参考资料:
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true"
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<behaviors>
<serviceBehaviors>
<behavior name="includeExceptions">
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_Default" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="Infinite" sendTimeout="01:00:00" portSharingEnabled="true" transferMode="Buffered" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
</security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
手动创建代理不会妨碍您将配置放在配置文件中; 您只需要在ClientBase派生的代理类中公开正确的构造函数重载,该代理类委托给ClientBase中的正确构造函数,该构造函数将在配置中查找端点的名称.
也就是说,您当然可以通过代码填写端点标识,您只需要创建正确类型的EndpointIdentity派生类并将其附加到实例化代理类时使用的EndpointAddress对象.像这样的东西:
EndpointIdentity epid = EndpointIdentity.CreateUpnIdentity("user@domain.fqdn");
EndpointAddress epaddr = new EndpointAddress(uri, epid);
MyClient client = new MyClient(epaddr);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10770 次 |
| 最近记录: |