3

I'm trying to connect to a Sharepoint instance to publish some content via a 3rd party tool.

I don't have control of the Sharepoint instance, but am assured my account has full permissions.

        ClientContext ctx = new ClientContext("https://thesharepointsite.com");
        ctx.Credentials = new System.Net.NetworkCredential(@"username", "password", "domain");
        Web w = ctx.Web;
        ctx.Load(w);
        ctx.ExecuteQuery();

On the ExecuteQuery line, I get the exception:

The remote server returned an error: (401) Unauthorized.

(There is no inner exception.)

I can confirm the url & credentials work when I login via a browser.

Based on this question, my assumption is that it is a permissions issue.

If that's the case, then what permission do I need to ask for?

Other questions' I've tried without success:

401 Error - Sharepoint 2007

SharePoint Server Authentication Error

401 unauthorized exception while reading data from the document library SharePoint 2010

Update

I've tried a variety of other queries with the same response. We have an Sharepoint, Office 365 instance and that works (using Remote Authentication). This is also why I believe its some sort of permission or access related.

This is on a customer's instance. I have only the one account. I believe if I asked for a 2nd one, it would have the same issue.

Community
  • 1
  • 1
Christian Payne
  • 7,081
  • 5
  • 38
  • 59

2 Answers2

1

Ask your SharePoint server administrator. They should be able to help you troubleshoot as well. There's not much we will be able to help you with if you don't have access to SharePoint, as the issue is most likely on the server side.

Kyle Trauberman
  • 25,414
  • 13
  • 85
  • 121
1

It turns out it was a configuration issue on the Sharepoint server.

On the Sharepoint server, the errors were being recorded on the Event Viewer. I was able to run the code above, with the same credentials on the inside of their network.

Christian Payne
  • 7,081
  • 5
  • 38
  • 59