Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

Unauthorized exception trying to use PSI WebService from within SharePoint WebPart/App Page with SharePoint Claims based authentication

$
0
0

Hello,

(SharePoint 2010 and Project Server 2010)

My testcase involves a SharePoint application page where the code simply connects to the PSI WCF based API and gets a list of projects from the server.  If I run my code on a SharePoint application running with Classic Authentication then everything works fine.  IF I run the code from a SharePoint application that is configured for Claims Based Authentication (NTLM on Claims) I get the following exception:

Message:  The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'NTLM'.
Inner Exception: The remote server returned an error: (401) Unauthorized.

Anyone have any luck connecting to PSI from within a Cliams based SP 2010 app?  More details below

Thanks, Jeff


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, ChannelBinding channelBinding)
   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.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 ProjectServerTestWebPart.SvcProject.Project.ReadProjectStatus(Guid projGuid, DataStoreEnum dataStore, String projName, Int32 projType)
   at ProjectServerTestWebPart.SvcProject.ProjectClient.ReadProjectStatus(Guid projGuid, DataStoreEnum dataStore, String projName, Int32 projType)
   at ProjectServerTestWebPart.Layouts.ProjectServerTestWebPart.RandD_ProjectServerTester.ProjectListButton_Click(Object sender, EventArgs e)
   at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

ProjectServerTestWebPart.* namespace is my code and ProjectServerTestWebPart.SvcProject is the namespace for the Service Reference to Project.svc.

I am running the code as domain Administrator who is also the Administrator of my PWA site I am trying to connect to.

Added the following to the SP application web.config:
<system.serviceModel>
 <!-- start jeff dev -->
  <behaviors>
   <endpointBehaviors>
    <behavior name="basicHttpBehavior">
     <clientCredentials>
      <windows allowedImpersonationLevel="Impersonation"/>
     </clientCredentials>
    </behavior>
   </endpointBehaviors>
  </behaviors>
 <!-- end jeff dev -->
 <bindings>
  <basicHttpBinding>
   <!-- start jeff dev -->
   <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>
 <!-- end jeff dev -->

  </basicHttpBinding>
 </bindings>
 <client>
  <endpoint address="http://dev-2010/pwa/_vti_bin/PSI/ProjectServer.svc" behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding" bindingConfiguration="basicHttpConf" contract="SvcProject.Project" name="multiHttp_Project" />
 </client>
</system.serviceModel>


My Code:
SvcProject.ProjectClient projectClient = new SvcProject.ProjectClient("multiHttp_Project");
SvcProject.ProjectDataSet projectDs;
using (OperationContextScope scope = new OperationContextScope(projectClient.InnerChannel))
{
 // Get a list of all published projects. Use ReadProjectStatus instead of
 // ReadProjectList, because the permission requirements are lower.
 projectDs = projectClient.ReadProjectStatus(
 Guid.Empty, // Read project by name.
 SvcProject.DataStoreEnum.PublishedStore,
 string.Empty, // Read the project specified by GUID.
 (int)PSLibrary.Project.ProjectType.Project);
}


Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>