none
How to convert my working Console App to a Web App? RRS feed

  • Question

  • I have a console application (from a Sample) working perfectly to get Project and Task information.  I now need to move it to my ASP.Net Application.  I added the app.config settings to my web.config and it is picking up the information ok. 

    But when I instantiate my Project DataSet:

                'Get Project Info from Project Server
                Dim projectDs As SvcProject.ProjectDataSet = projectClient.ReadProjectStatus(Guid.Empty, _
                                 SvcProject.DataStoreEnum.WorkingStore, DataRS("ProjectNumber"), _
                                 CInt(PSLibrary.Project.ProjectType.Project))

    I get the following error: 

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

    My Web.Config:


      <system.serviceModel>
        <behaviors>
          <endpointBehaviors>
            <behavior name="basicHttpBehavior">
              <clientCredentials>
                <windows allowedImpersonationLevel="Impersonation" />
              </clientCredentials>
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <bindings>
          <basicHttpBinding>
            <binding name="basicHttpConf" sendTimeout="01:00:00" maxBufferPoolSize="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://myServer:22986/pwa/_vti_bin/PSI/ProjectServer.svc"
              behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding"
              bindingConfiguration="basicHttpConf" contract="SvcProject.Project"
              name="basicHttp_Project" />

          <endpoint address="http://myServer:22986/pwa/_vti_bin/PSI/ProjectServer.svc"
              behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding"
              bindingConfiguration="basicHttpConf" contract="SvcResource.Resource"
              name="basicHttp_Resource" />

          <endpoint address="http://myServer:22986/pwa/_vti_bin/PSI/ProjectServer.svc"
              behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding"
              bindingConfiguration="basicHttpConf" contract="SvcQueueSystem.QueueSystem"
              name="basicHttp_QueueSystem" />
        </client>
      </system.serviceModel>


    Todd Klost


    • Edited by Todd Klost Tuesday, December 11, 2012 9:10 PM Grammer
    Tuesday, December 11, 2012 9:10 PM

Answers

  • I found out you have to change the <WCFService>.

    .ClientCredentials.Windows.ClientCredential

    to a valid Project Server 2010 user (I choose my Farm Admin):

    Code Change:

    Private Shared projectClient As SvcProject.ProjectClient

    ...
                Dim ProjectServer2010UserID As String = oAlertSettings.GetAppSetting("ProjectServer2010UserID")
                Dim ProjectServer2010UserPassword As String = oAlertSettings.GetAppSetting("ProjectServer2010UserPassword")
                Dim ProjectServer2010UserDomain As String = oAlertSettings.GetAppSetting("ProjectServer2010UserDomain")

                projectClient.ClientCredentials.Windows.ClientCredential = New NetworkCredential(ProjectServer2010UserID, ProjectServer2010UserPassword, ProjectServer2010UserDomain)

                'Get Project Info from Project Server
                Dim projectDs As SvcProject.ProjectDataSet = projectClient.ReadProjectStatus(Guid.Empty, _
                     SvcProject.DataStoreEnum.WorkingStore, DataRS("ProjectNumber"), 0)
    ...


    Todd Klost

    Wednesday, December 12, 2012 4:52 PM
  •  Correct Todd, and this user if it is admin as shown and has the my org category can then update all projects in the server. 

    Ray Letts Arbutus Solutions


    Thursday, December 13, 2012 8:06 PM

All replies

  • I found out you have to change the <WCFService>.

    .ClientCredentials.Windows.ClientCredential

    to a valid Project Server 2010 user (I choose my Farm Admin):

    Code Change:

    Private Shared projectClient As SvcProject.ProjectClient

    ...
                Dim ProjectServer2010UserID As String = oAlertSettings.GetAppSetting("ProjectServer2010UserID")
                Dim ProjectServer2010UserPassword As String = oAlertSettings.GetAppSetting("ProjectServer2010UserPassword")
                Dim ProjectServer2010UserDomain As String = oAlertSettings.GetAppSetting("ProjectServer2010UserDomain")

                projectClient.ClientCredentials.Windows.ClientCredential = New NetworkCredential(ProjectServer2010UserID, ProjectServer2010UserPassword, ProjectServer2010UserDomain)

                'Get Project Info from Project Server
                Dim projectDs As SvcProject.ProjectDataSet = projectClient.ReadProjectStatus(Guid.Empty, _
                     SvcProject.DataStoreEnum.WorkingStore, DataRS("ProjectNumber"), 0)
    ...


    Todd Klost

    Wednesday, December 12, 2012 4:52 PM
  •  Correct Todd, and this user if it is admin as shown and has the my org category can then update all projects in the server. 

    Ray Letts Arbutus Solutions


    Thursday, December 13, 2012 8:06 PM
  • Ray, what about using impersonation to CreateTimeSheets? If I have to impersonate 'Joe Smith' who is just an ordinary user, how am I ever to impersonate him to do any work such as creating timesheets when i'm getting this error too?:

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

    Do all my users have to be super-users? or is there a specific credential that will prevent this authentication problem.

    Todd.


    Todd Klost

    Wednesday, January 23, 2013 4:15 PM