【发布时间】:2021-09-03 11:42:26
【问题描述】:
我正在尝试按如下方式设置客户端/服务器方案:
客户:
- WPF
- .NET Framework 4.7.2
服务器:
- ASP.NET
- .NET Framework 4.7.2
- WCF
- IIS 托管
- Windows 身份验证
- 仅 HTTPS(端口 80 未映射)
WCF 服务使用 Windows 身份验证连接到 MSSQL,应用程序池使用域服务帐户(用于调试它使用我的 Windows 帐户)。
我想要完成的是:
- WPF 客户端使用 Windows 身份验证进行身份验证
- 仅允许选定的一组用户连接到 IIS WCF 服务
- HTTP 流量仅通过 HTTPS 传输运行。
我的主要问题是配置 IIS 和 Web.Config(绑定)以使一切正常工作,最好 WCF 客户端不需要在代码中声明绑定和端点。 (var client = new wcfclient() .. 就是这样)。
IIS 配置:
- 证书:是自签名 SSL 证书(在生产中是真实的)
- 身份验证:启用 Windows 身份验证,其余的被禁用(我需要担心 Negotiate 与 NTLM 吗??)
- 绑定:HTTPS
.NET 授权规则:
- 拒绝:匿名用户(本地)
- 允许:(逗号分隔的域用户列表(本地)
- 拒绝:所有用户(本地)
- 允许:所有用户(继承)
System.Web
- 身份验证模型="Windows"
System.ServiceModel
<system.serviceModel>
<services>
<service name="Modelkatalog.Service.CatalogService">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="secureHttpBindingConfiguration"
contract="Modelkatalog.Service.ICatalogService"/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="secureHttpBindingConfiguration">
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
客户端配置
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ICatalogService">
<security mode="Transport" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://modelkatalog.local/CatalogService.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_ICatalogService"
contract="CatalogService.ICatalogService"
name="WSHttpBinding_ICatalogService">
<identity>
<!-- THIS DOESN'T LOOK RIGHT -->
<userPrincipalName value="mk@domain.local" />
</identity>
</endpoint>
</client>
</system.serviceModel>
wsHttpBinding 与 basicHttpBinding 我一直在阅读每个内容并尝试了两个..它们最终都会出现某种 HTTP 协商错误或 HTTP 与 HTTPS 地址映射的一些错误
目前我得到这个“从服务器收到的身份验证标头是'Negotiate,NTLM'”
我如何做到这一点?
【问题讨论】:
标签: wpf wcf iis windows-authentication ntlm