none
Connecting to PSI with WCF returns 401 (Unauthorized) RRS feed

  • Question

  • Hi,

    I have a test-application created according to 'How to: Use Impersonation with WCF'.

    In this application a connection is being made with WCF to a MS Project Server.

    app.config:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <system.serviceModel>
        <behaviors>
          <endpointBehaviors>
            <behavior name="xx">
              <clientCredentials>
                <windows allowedImpersonationLevel="Impersonation" />
              </clientCredentials>
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <bindings>
          <basicHttpBinding>
            <binding name="basicHttpConf" sendTimeout="01:00:00" maxBufferSize="500000000" maxReceivedMessageSize="500000000">
              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="500000000" />
              <security mode="TransportCredentialOnly">
                <transport clientCredentialType="Ntlm" realm="http" />
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://xxxx/pwa/_vti_bin/PSI/ProjectServer.svc"
                    behaviorConfiguration="xx" binding="basicHttpBinding"
                    bindingConfiguration="basicHttpConf" contract="SvcResource.Resource"
                    name="basicHttp_Resource" />
          
        </client>
      </system.serviceModel>
    </configuration>

    When I try to connect to the endpoint I get the following error:

    System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication schem
    e 'Ntlm'. The authentication header received from the server was 'NTLM'. ---> System.Net.WebException: The remote server
     returned an error: (401) Unauthorized.
       at System.Net.HttpWebRequest.GetResponse()
       at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan time
    out)
       --- End of inner exception stack trace ---
    
    Server stack trace:
       at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse r
    esponse, WebException responseException, HttpChannelFactory`1 factory)
       at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResp
    onse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
       at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan time
    out)
       at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, O
    bject[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntim
    e operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Do I have to set anything in MS Project Server besides the instructions stated in 'How to: Use Impersonation with WCF'?

    Or is there another thing I'm missing?

    Paul

    Wednesday, August 7, 2013 11:18 AM

All replies

  • Have you try changing

    clientCredentialType="Ntlm"

    to

    clientCredentialType="Windows"

    Thursday, August 8, 2013 8:52 PM
  • Didn't work on Impersonation application for PS 2010, but for PS 2007 you need to run impersonation application using PS Service account. Else you'll get unauthorized access.

    So to can you please try to run your application using PS 2010 Service Account.

    Please correct me in case I am wrong in my understanding.

    Thanks !!!


    Sachin Vashishth MCTS

    Sunday, August 11, 2013 6:02 PM