1

Windows 認証を使用する WCF ajax 対応の Web サービスがあります。ローカル PC でアプリケーションを実行すると完全に動作しますが、ホストすると、クライアント資格情報をサービスに渡したくありません。

次のエラーが発生し続けます: ユーザー 'NT AUTHORITY\ANONYMOUS LOGON' のログインに失敗しました

必要なすべての構成が含まれていると思いますが、よくわかりません。

私の Web 設定:

    <?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
    </modules>
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>
  <system.web>
    <authentication mode="Windows"/>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
  </system.web>
  <connectionStrings>
    <add name="reportEntities" connectionString="metadata=res://*/Entities.TNTReport.csdl|res://*/Entities.TNTReport.ssdl|res://*/Entities.TNTReport.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=UECZATNT02;initial catalog=report;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
  <!--<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="PassThrough">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="TNTQueryEngine.Services.InformationServicesAspNetAjaxBehavior">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
    <services>
      <service name="TNTQueryEngine.Services.InformationServices">
        <endpoint address="" behaviorConfiguration="TNTQueryEngine.Services.InformationServicesAspNetAjaxBehavior"
          binding="webHttpBinding" contract="TNTQueryEngine.Services.InformationServices" />
      </service>
    </services>
  </system.serviceModel>-->
  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="MyBindingForWindowsAuth">
          <security mode="TransportCredentialOnly">
            <!-- For Ntlm to work do => IIS right click Win Auth => Providers => Move NTLM up  -->
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceTypeBehaviors" >
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceAuthorization principalPermissionMode="UseAspNetRoles" impersonateCallerForAllOperations="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="XYZ">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
      <service name="TNTQueryEngine.Services.InformationServices" behaviorConfiguration="MyServiceTypeBehaviors">
        <endpoint address="" binding="webHttpBinding" bindingConfiguration="MyBindingForWindowsAuth"
                  contract="TNTQueryEngine.Services.InformationServices" behaviorConfiguration="XYZ" />
        <endpoint address="mex" binding="webHttpBinding" bindingConfiguration="MyBindingForWindowsAuth" contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>

1つのメソッドを持つ私のWCFサービス:

namespace TNTQueryEngine.Services
{
    [ServiceContract(Namespace = "InfoServices")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class InformationServices 
    {
        reportEntities RP = new reportEntities();
        [OperationContract, WebGet(ResponseFormat = WebMessageFormat.Json)]
        [OperationBehavior(Impersonation = ImpersonationOption.Required)]
        public List<Receiving> GETReceiving(DateTime DATE)
        {
            return (from SS in RP.spQueryEngineGETReceivingSummary(DATE)
                    where SS.QTY > 0
                    select new Receiving
                    {
                        ReceivedDate = DATE,
                        Model = SS.Model,
                        Qty = (int)SS.QTY
                    }
                    ).ToList();
        }

    }
}

何がうまくいかないのか本当にわかりません。ご協力ありがとうございました

4

0 に答える 0