如何将Windows身份验证添加到WCF应用程序

时间:2011-10-10 08:30:22

标签: c# .net wcf

我目前正在使用C#编写WCF项目。我对整个.NET领域都很陌生,因为我通常在做Java,所以请允许我提一个简单的问题:

如何让我的应用程序要求使用Windows密码的凭据(HTTP摘要/基本)?我尝试使用谷歌搜索,但许多信息都是误导性的。

这是我的web.config目前的样子:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </modules>
  </system.webServer>

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true">
        </standardEndpoint>
      </webHttpEndpoint>
    </standardEndpoints>
  </system.serviceModel>

</configuration>

1 个答案:

答案 0 :(得分:2)

试试这个:http://msdn.microsoft.com/en-us/library/ff648505.aspx

向下滚动到XML代码段。

请注意绑定设置中的安全模式:

      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows" />
      </security>