开发者

The HTTP request is unauthorized with client authentication schem

I have a mega headache from this, so any help you guys can offer is welcome.

After several months of a project, which was working, being in limbo when I go back to it I now receive this error:

The HTTP request is unauthorized with client authentication schem e 'Negotiate'. The authentication header received from the server was 'Negotiate ,NTLM'.

I have been all over the Googles with this and a bunch of StackOverflow postings. None of what I have found has worked. One important thing to notice is that if I remove the NetworkCredential and just run the console app under my own user context, it works fine. And the WCF methods are restricted to members of a specific AD group, to which both I and the macrequest user belong. I have reset the user's password and double checked it is still in said group.

IIS is configured to use Anonymous and Windows authentication as in the figure:

The HTTP request is unauthorized with client authentication schem

My client code is thus:

try
            {
                svc.ClientCredentials.Windows.ClientCredential = new NetworkCredential(
                    "macrequest",
                    "password",
                    "domain.net"
                    );
                svc.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
                try
                {
                    Console.WriteLine("Version: {0}", svc.GetVersion());
                    Console.WriteLine("Received MAC: {0}", svc.GetSingleAddress("Console app"));



                }
                catch (FaultException<ServiceReference1.DefaultFaultContract> ex)
                {
                    Console.WriteLine("Error: {0}", ex.Message);
                }
                Console.Read();                }
            catch (Exception e)
            {
                Console.WriteLine("General error: {0}", e.Message);
            }
            Console.Read();

And here is my Web.config

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <sectionGroup name="system.serviceModel">
      <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" 

allowDefinition="MachineToApplication" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <system.web>
    <httpModules>
      <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </httpModules>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <roleManager enabled="true" />
    <authentication mode="Windows">
    </authentication>
    <profile>
      <properties>
        <add name="FriendlyName" />
      </properties>
    </profile>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <add name="DomainServiceModule" preCondition="managedHandler" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, 

PublicKeyToken=31BF3856AD364E35" />
    </modules>
  </system.webServer>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="WebBehavior">
          <webHttp />开发者_开发知识库;
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <customBinding>
        <binding name="MacDatabase.Web.MacDbService.customBinding0">

          <binaryMessageEncoding />

          <httpTransport authenticationScheme="Negotiate" proxyAuthenticationScheme="Anonymous" />



        </binding>
      </customBinding>
    </bindings>
    <services>
      <service name="MacDatabase.Web.MacDbService">
        <endpoint address="" binding="customBinding" bindingConfiguration="MacDatabase.Web.MacDbService.customBinding0" contract="MacDatabase.Web.MacDbService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <connectionStrings>
    <add name="MacDbEntities" connectionString="metadata=res://*/MacDbModel.csdl|res://*/MacDbModel.ssdl|res://*/MacDbModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=server.domain.net;Initial 

Catalog=Testing;Persist Security Info=True;User ID=MAC_DB_Login;Password=wR5preGa;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜