none
CSOM even from the SDK 403 forbidden RRS feed

  • Question

  • I'm spinning my wheels on this permission thing,

    It may be my environment, Claims with Windows and FBA, I have the everything but the app catalog configured but I don't really want to build apps, I'd rather stick with solutions.

    Just to begin with I tried the NetworkCredetial assignment but I got a feeling things might be different know with claims. (claimshelper but for onprem)?

    Tuesday, April 2, 2013 3:28 PM

All replies

  • Here is what I found works, I didn't figure it out, So an Application page can access the CSOM when the Project Server is set up with NTLM and FBA. The earliest reference I found to this is here.  http://buyevich.blogspot.ca/2011/03/accessing-mixed-authentication-web-app.html

    using System;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using System.Data.SqlClient;
    using Microsoft.ProjectServer.Client;
    using System.Net;
    using Microsoft.SharePoint.Administration.Claims;
    using Microsoft.SharePoint.Client;


    namespace AppPage.Layouts.AppPage
    {
        public partial class ApplicationPage1 : LayoutsPageBase
        {
          
            protected void Button1_Click(object sender, EventArgs e)
            {

                string webUrl = "http://server/pwa";
                NetworkCredential credentials = new System.Net.NetworkCredential("user","pasword","DOMAIN" );
                using (ProjectContext projContext = new ProjectContext(webUrl))
                {
                    //projContext.Credentials = System.Net.CredentialCache.DefaultCredentials;
                    projContext.Credentials = credentials;
                    projContext.ExecutingWebRequest += new EventHandler<WebRequestEventArgs>(clientContext_ExecutingWebRequest);

                    projContext.Load(projContext.Projects);
                    projContext.ExecuteQuery();
                    foreach (PublishedProject pubProj in projContext.Projects)
                    {
                        this.TextBox1.Text = this.TextBox1.Text + pubProj.Id.ToString();
                    }
                }        

            }


            static void clientContext_ExecutingWebRequest(object sender, WebRequestEventArgs e)
            {
                e.WebRequestExecutor.WebRequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
            }

           

            protected void Page_Load(object sender, EventArgs e)
            {

            }
        }
    }

    Wednesday, April 3, 2013 11:59 AM