IIS WCF服务以域用户身份

时间:2016-09-19 16:19:24

标签: wcf iis service dns

我目前正在开发我的第一个WCF Web服务,在IIS 8.5中进行托管。我目前遇到了一个问题。

如果我使用ApplicationPoolIdentity,该服务至少会运行。我可以在浏览器中检查服务并查看WSDL。如果我将IIS中的标识更改为域用户,则在requesttet时服务将关闭。我需要它以某些权限运行,因为该服务可以与我们的Active Directory一起使用。

我的Webconfig:

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

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5"/>
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
    </httpModules>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" 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="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="TransportSecurity">
          <security mode ="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
    <services>
      <service name="net.hasuma.webservices.portalx.AdfsService">
        <endpoint address="" contract="net.hasuma.webservices.portalx.IAdfsService" 
                  bindingNamespace="net.hasuma.webservices.portalx" binding="wsHttpBinding"
                  bindingConfiguration ="TransportSecurity"/>
        <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding"/>
      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="ApplicationInsightsWebTracking"/>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
        preCondition="managedHandler"/>
    </modules>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
    <validation validateIntegratedModeConfiguration="false"/>    
  </system.webServer>

</configuration>

我知道关闭它的问题是什么(身份),但我不知道为什么会发生这种情况。我认为我的webconfig出了问题。

一如既往有一些限制。该服务可以在AD目录中写入,因此只允许SSL。

1 个答案:

答案 0 :(得分:0)

好的,我是正式的傻瓜。我在使用Windows Server的VM上进行测试,但我没有加入AD。域用户不知道,因此服务关闭。我很抱歉打扰你的愚蠢。