I am trying to access a list in a site collection of different farm using CSOM.

But I am getting the error:

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

Code I used is below.

 using (ClientContext ctx = new ClientContext(URL))
     Web web = ctx.Site.RootWeb;

Always getting the authentication error. Is any special configuration required between farms? Please help. Thanks in advance.

2 Answers 2


Don't know if I have a proper answer for this but it might help the diagnosis if you ensure that the application pool account of the first web application has access to the content in the second farm's web application.

If that works, it sounds like the client credentials may not be getting passed from the client through to the second farm, probably indicating a Kerberos configuration issue.

  • Thanks for the reply. The farm administrator in both farms are same user account. Also we have reconfigured the Kerbos again using this link sharepointassist.com/2011/02/21/… Still getting same error. Any other option?
    – Abhi
    Mar 7, 2016 at 11:26
  • Now its working. Actually it was the issue in the request and kerberos. Thanks for your help :-)
    – Abhi
    Mar 9, 2016 at 6:34

Maybe one of these steps can help.

a) make sure you (the account you are using) has access to that site

b) try

ctx.Credentials = CredentialCache.DefaultNetworkCredentials;

c) alternatively you can try explicitly setting up the credentials

ctx.Credentials = new NetworkCredential("username", "password", "domain");

more here: HTTP 401, Unauthorized using the Managed Client Object Model

  • Yep, you would need to authenticate as you are using the CSOM against a new farm, you are only currently authenticated on the farm you are on. Pass along credentials as Tiago mentions and you good to go. Mar 4, 2016 at 9:52
  • @Tiago Thanks for the reply. I already tried these steps. But no use. Still getting the same error. Anything to change in web.config or anywhere?
    – Abhi
    Mar 4, 2016 at 9:53
  • @Chunkyfeather I tried using NTLM webapps and kerbos authentications. No difference.
    – Abhi
    Mar 4, 2016 at 9:58
  • don't think you need to setup anything. maybe double check your code and your access to that list through the browser Mar 4, 2016 at 10:17

Your Answer

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

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