Sep 01 2022 11:48 AM
I have MS Project Server running on a SP 2016 on-prem SharePoint farm.
I have set up server side event handlers for the OnPublishing and OnPublished events. Everything is configured correctly for those, I do extensive logging and I know that they are fired at the appropriate times.
My goal is to set a project scoped enterprise custom field from that server side code.
I have tried loading/opening the custom field and specific projects using both the Project Server CSOM (Microsoft.ProjectServer.Client) and by making requests to the REST API using System.Net.Http.HttpClient.
Nothing seems to work. Using the CSOM I get a (403) Forbidden error, and making REST requests gets me a System.UnauthorizedAccessException.
I've tried both with and without using SPSecurity.RunWithElevatedPrivileges. I know that that effectively runs the code as the app pool account, and I explicitly added the app pool service account to the "Administrators for Project Web App" group. I also noticed that there is a "Microsoft Project Server Events" service running in the background, and that service is also using the same account as the app pool, so theoretically adding that account to the Administrators group should give it full control.
So why am I getting these "unauthorized" and "forbidden" errors? How can I access a project and set an enterprise custom field from a server side event handler?
This should be possible, somehow, right? Or is it just completely unallowed and impossible to do?
The only other thing I can think of is that we have switched over from windows auth to claims auth... What do I need to do to use the Project Server CSOM or REST API in a claims-y way?
Sep 02 2022 05:41 AM
Hello @DylanCristy ,
Does the user account that you are specifying as part of the auth have edit access to that project you are trying to update? Have you tried running the update code in isolation in a console app etc. Does that auth OK?
Paul
Sep 02 2022 09:01 AM