0

I need to read the properties for the current sharepoint user in a C# method, using CSOM.

I've tried using an example from http://www.c-sharpcorner.com/code/490/how-to-get-the-current-users-properties-using-csom-in-sharep.aspx

But there's a 403 error during ExecuteQuery()

     ClientContext clientContext = new ClientContext(siteURL); 
            PeopleManager peopleManager = new PeopleManager(clientContext);  
            PersonProperties personProperties = peopleManager.GetMyProperties();  
            clientContext.Load(personProperties, p => p.AccountName, p => p.Email, p => p.DisplayName);  
            clientContext.ExecuteQuery();  

Why am I forbidden from accessing the user properties? Does it require some special authentication?

the thing is that I am able to call the getmyproperties service in javascript by a regular get request, so I figured that no authorization was required to access them

siteUrl + "/_api/sp.userprofiles.peoplemanager/getmyproperties"
1
  • Seems like I get a 403 error from executing ANY query. Even something like this using (var clientContext = new ClientContext(siteUrl)) { Web web = clientContext.Web; clientContext.Load(web); clientContext.ExecuteQuery(); } Apr 27, 2015 at 14:07

1 Answer 1

0

The problem was that the code was running in the app pool which was not trusted to access the site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.