none
HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'

    Question

  • I am trying to set the app.config values a runtime for a SharePoint service (lists.asmx) using WCF and I have this error:

    System.ServiceModel.Security.MessageSecurityException was unhandled
      Message="The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'."
      Source="mscorlib"
      StackTrace:
        Server stack trace:
           at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory factory)
           at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException)
           at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
           at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
           at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
           at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
           at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
           at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
           at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
        Exception rethrown at [0]:
           at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
           at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
           at TEST.WSLists.ListsSoap.GetAttachmentCollection(GetAttachmentCollectionRequest request)
           at TEST.WSLists.ListsSoapClient.TEST.WSLists.ListsSoap.GetAttachmentCollection(GetAttachmentCollectionRequest request) in C:\6\DEBUG\TEST\TEST\Service References\WSLists\Reference.cs:line 2781
           at TEST.WSLists.ListsSoapClient.GetAttachmentCollection(String listName, String listItemID) in C:\6\DEBUG\TEST\TEST\Service References\WSLists\Reference.cs:line 2789
           at TEST.Program.Run() in C:\6\DEBUG\TEST\TEST\Program.cs:line 74
           at TEST.Program.Main() in C:\6\DEBUG\TEST\TEST\Program.cs:line 20
      InnerException: System.Net.WebException
           Message="The remote server returned an error: (401) Unauthorized."
           Source="System"
           StackTrace:
                at System.Net.HttpWebRequest.GetResponse()
                at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
           InnerException:
     



    CODE =====================================================>

    WSLists.

    ListsSoapClient lsc = new WSLists.ListsSoapClient("ListsSoap");

    lsc.ClientCredentials.Windows.ClientCredential =

    new NetworkCredential("casahl\\ss2010", "1234");

    lsc.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.

    TokenImpersonationLevel.Delegation;

     

     

    Uri BaseAddress = new Uri("http://ss20x/sites/HOME/_vti_bin/Lists.asmx");

     

     

    ServiceHost host = new ServiceHost(typeof(WSLists.ListsSoapClient), BaseAddress);

     

    BasicHttpBinding basicHttpBinding = new BasicHttpBinding();

    basicHttpBinding.Security.Mode =

    BasicHttpSecurityMode.TransportCredentialOnly;

    basicHttpBinding.Security.Transport.ClientCredentialType =

    HttpClientCredentialType.Ntlm;

     

    host.AddServiceEndpoint(

    typeof(WSLists.ListsSoap), basicHttpBinding, "");

    host.AddServiceEndpoint(

    typeof(WSLists.ListsSoap), basicHttpBinding, "http://ss20x/sites/HOME/JawadSite/_vti_bin/Lists.asmx");

    host.Open();

     

    XmlNode ndAttach = lsc.GetAttachmentCollection("Tasks", "1");   <<<<<<<<< ERROR OCCURS HERE*************

     

    foreach (XmlNode ndAtt in ndAttach.ChildNodes)

    {

     

    string url2 = ndAtt.InnerText;

    }

    Thursday, March 04, 2010 6:52 AM

Answers

  • Hi ,

    Based on your description, it looks like that the client configuration file is not correct here for client authentication. You can have a look NTLM Authentication in Windows Communication Foundation for your reference about how to fix this issue with the client configuration:
    http://blogs.msdn.com/publicsector/archive/2005/10/19/482833.aspx

    Some key things to note, in no particular order:

    • endpoint configurationName (ex. "dmb") is what you pass to your contructor when you create the Indigo proxy.
    • endpoint bindingConfiguration (ex. "dmb1") tells which binding instance to use.  It must match binding configurationName.
    • If you omit bindingConfiguration, the default settings for the binding (ex. "basicHttpBinding") will be used.
    • security mode of "None" always uses anonymous authentication, despite what the transport clientCredentialType is set to.
    • security mode of "Transport" requires https.
    • transport clientCredentialType of  "Windows" means to negotiate the authentication type with the web server.  The development web server doesn't support this, so you have to use Ntlm.


    Best regards,
    Riquel
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, March 09, 2010 3:31 AM
    Moderator

All replies

  • I am trying to set the app.config values a runtime for a SharePoint service (lists.asmx) using WCF and I have this error:

    System.ServiceModel.Security.MessageSecurityException was unhandled
      Message="The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'."
      Source="mscorlib"
      StackTrace:
        Server stack trace:
           at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory factory)
           at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException)
           at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
           at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
           at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
           at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
           at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
           at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
           at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
        Exception rethrown at [0]:
           at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
           at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
           at TEST.WSLists.ListsSoap.GetAttachmentCollection(GetAttachmentCollectionRequest request)
           at TEST.WSLists.ListsSoapClient.TEST.WSLists.ListsSoap.GetAttachmentCollection(GetAttachmentCollectionRequest request) in C:\6\DEBUG\TEST\TEST\Service References\WSLists\Reference.cs:line 2781
           at TEST.WSLists.ListsSoapClient.GetAttachmentCollection(String listName, String listItemID) in C:\6\DEBUG\TEST\TEST\Service References\WSLists\Reference.cs:line 2789
           at TEST.Program.Run() in C:\6\DEBUG\TEST\TEST\Program.cs:line 74
           at TEST.Program.Main() in C:\6\DEBUG\TEST\TEST\Program.cs:line 20
      InnerException: System.Net.WebException
           Message="The remote server returned an error: (401) Unauthorized."
           Source="System"
           StackTrace:
                at System.Net.HttpWebRequest.GetResponse()
                at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
           InnerException:
     



    CODE =====================================================>

    WSLists.

     

    ListsSoapClient lsc = new WSLists.ListsSoapClient("ListsSoap");

    lsc.ClientCredentials.Windows.ClientCredential =

     

    new NetworkCredential("casahl\\ss2010", "1234");

    lsc.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.

     

    TokenImpersonationLevel.Delegation;

     

     

     

    Uri BaseAddress = new Uri("http://ss20x/sites/HOME/_vti_bin/Lists.asmx");

     

     

     

    ServiceHost host = new ServiceHost(typeof(WSLists.ListsSoapClient), BaseAddress);

     

     

    BasicHttpBinding basicHttpBinding = new BasicHttpBinding();

    basicHttpBinding.Security.Mode =

     

    BasicHttpSecurityMode.TransportCredentialOnly;

    basicHttpBinding.Security.Transport.ClientCredentialType =

     

    HttpClientCredentialType.Ntlm;

     

    host.AddServiceEndpoint(

     

    typeof(WSLists.ListsSoap), basicHttpBinding, "");

    host.AddServiceEndpoint(

     

    typeof(WSLists.ListsSoap), basicHttpBinding, "http://ss20x/sites/HOME/JawadSite/_vti_bin/Lists.asmx");

    host.Open();

     

     

    XmlNode ndAttach = lsc.GetAttachmentCollection("Tasks", "1");   <<<<<<<<< ERROR OCCURS HERE*************

     

     

    foreach (XmlNode ndAtt in ndAttach.ChildNodes)

    {

     

     

    string url2 = ndAtt.InnerText;

    }

    Thursday, March 04, 2010 6:53 AM
  • Hi ,

    Based on your description, it looks like that the client configuration file is not correct here for client authentication. You can have a look NTLM Authentication in Windows Communication Foundation for your reference about how to fix this issue with the client configuration:
    http://blogs.msdn.com/publicsector/archive/2005/10/19/482833.aspx

    Some key things to note, in no particular order:

    • endpoint configurationName (ex. "dmb") is what you pass to your contructor when you create the Indigo proxy.
    • endpoint bindingConfiguration (ex. "dmb1") tells which binding instance to use.  It must match binding configurationName.
    • If you omit bindingConfiguration, the default settings for the binding (ex. "basicHttpBinding") will be used.
    • security mode of "None" always uses anonymous authentication, despite what the transport clientCredentialType is set to.
    • security mode of "Transport" requires https.
    • transport clientCredentialType of  "Windows" means to negotiate the authentication type with the web server.  The development web server doesn't support this, so you have to use Ntlm.


    Best regards,
    Riquel
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, March 09, 2010 3:31 AM
    Moderator
  • Hai 

    I am trying to add web service in vs 2010 for developing project server workflow through psi.

    But i got the Following errors.

     

    There was an error downloading 'http://expertspm/pwa'.

    The request failed with the error message:

    --<html>

    <head>

            <title>Project Server 2010 requires at least Microsoft Internet Explorer 7.0.</title>

            <style>

             body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 

             p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}

             b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}

             H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }

             H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }

             pre {font-family:"Lucida Console";font-size: .9em}

             .marker {font-weight: bold; color: black;text-decoration: none;}

             .version {color: gray;}

             .error {margin-bottom: 10px;}

             .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }

            </style>

        </head>

     

        <body bgcolor="white">

     

                <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>

     

                <h2> <i>Project Server 2010 requires at least Microsoft Internet Explorer 7.0.</i> </h2></span>

     

                <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

     

                <b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

     

                <br><br>

     

                <b> Exception Details: </b>Microsoft.SharePoint.SPException: Project Server 2010 requires at least Microsoft Internet Explorer 7.0.<br><br>

     

                <b>Source Error:</b> <br><br>

     

                <table width=100% bgcolor="#ffffcc">

                   <tr>

                      <td>

                          <code>

     

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>

     

                      </td>

                   </tr>

                </table>

     

                <br>

     

                <b>Stack Trace:</b> <br><br>

     

                <table width=100% bgcolor="#ffffcc">

                   <tr>

                      <td>

                          <code><pre>

     

    [SPException: Project Server 2010 requires at least Microsoft Internet Explorer 7.0.]

       Microsoft.Office.Project.PWA.PJBaseWebPartPage.OnPreInit(EventArgs e) +277

       System.Web.UI.Page.PerformPreInit() +42

       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1256

    </pre></code>

     

                      </td>

                   </tr>

                </table>

     

                <br>

     

                <hr width=100% size=1 color=silver>

     

                <b>Version Information:</b> Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016

     

                </font>

     

        </body>

    </html>

    <!-- 

    [SPException]: Project Server 2010 requires at least Microsoft Internet Explorer 7.0.

       at Microsoft.Office.Project.PWA.PJBaseWebPartPage.OnPreInit(EventArgs e)

       at System.Web.UI.Page.PerformPreInit()

       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    [HttpUnhandledException]: Exception of type 'System.Web.HttpUnhandledException' was thrown.

       at System.Web.UI.Page.HandleError(Exception e)

       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

       at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

       at System.Web.UI.Page.ProcessRequest()

       at System.Web.UI.Page.ProcessRequest(HttpContext context)

       at ASP.DEFAULT_ASPX__1514027361.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\e22c2559\92c7e946\App_Web_default.aspx_-1514027361.ppmmz8cp.0.cs:line 0

       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

    -->

    --.

    Metadata contains a reference that cannot be resolved: 'http://expertspm/pwa'.

    The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'.

    The remote server returned an error: (401) Unauthorized.

    If the service is defined in the current solution, try building the solution and adding the service reference again.

    Can u Help me ..

    Thanks in advance

    iqbalkmk

    Tuesday, April 27, 2010 6:54 AM
  • hi

    i resolve the issued by changing the app.config in clilent like:

     

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
     <system.serviceModel>
      <bindings>
       <basicHttpBinding>
        <binding name="BasicHttpBinding_BusinessDataCatalogSharedService"
          closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
          sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false"
          hostNameComparisonMode="StrongWildcard" maxBufferSize="999999"
          maxBufferPoolSize="9999999" maxReceivedMessageSize="999999"
          messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
         <readerQuotas maxDepth="99" maxStringContentLength="999999" maxArrayLength="999999"
           maxBytesPerRead="999999" maxNameTableCharCount="999999" />
         <security mode="TransportCredentialOnly">
          <transport clientCredentialType="Ntlm" proxyCredentialType="None"
            realm="">
           <extendedProtectionPolicy policyEnforcement="Never" />
          </transport>
          <message clientCredentialType="UserName" algorithmSuite="Default" />
         </security>
        </binding>
        <binding name="BasicHttpBinding_BusinessDataCatalogSharedService1"
          closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
          sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false"
          hostNameComparisonMode="StrongWildcard" maxBufferSize="999999"
          maxBufferPoolSize="9999999" maxReceivedMessageSize="999999"
          messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
         <readerQuotas maxDepth="99" maxStringContentLength="999999" maxArrayLength="999999"
           maxBytesPerRead="999999" maxNameTableCharCount="999999" />
         <security mode="Transport">
          <transport clientCredentialType="Ntlm" proxyCredentialType="None"
            realm="">
           <!--<extendedProtectionPolicy policyEnforcement="Never" />-->
          </transport>
          <message clientCredentialType="UserName" algorithmSuite="Default" />
         </security>
        </binding>
       </basicHttpBinding>
      </bindings>
      <client>
       <endpoint address="http://SUT02/_vti_bin/BdcAdminService.svc"
         binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_BusinessDataCatalogSharedService"
         contract="BusinessDataCatalogSharedService" name="BasicHttpBinding_BusinessDataCatalogSharedService" />
       <endpoint address="https://SUT02:443/_vti_bin/BdcAdminService.svc"
         binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_BusinessDataCatalogSharedService1"
         contract="BusinessDataCatalogSharedService" name="BasicHttpBinding_BusinessDataCatalogSharedService1" />
      </client>
     </system.serviceModel>
    </configuration>

    this two kind of binding is ok.

    <security mode="TransportCredentialOnly">

    or

    <security mode="Transport">

     

    Tuesday, June 29, 2010 6:02 AM