Here is my scenario:-

I have my Sharepoint server hosted on Domain A and I have my machine on Domain B. There is not any trust between Domain A and Domain B.

I am trying to access the Sharepoint Document library from my machine to Sharepoint server which is on Domain A.

Now when i used this code:-

ClientContext clientContext = new ClientContext(siteURL);
clientContext.Credentials = new System.Net.NetworkCredential(username,password,domain);

I got the following error:-

The remote server returned an error: (401) Unauthorized 

I want to know (Correct me if i am wrong) is it possible to access sharepoint document library accross the domain without having trust between each other and the only solution i think is my machine should be on the Domain A.


I transfered my machine on Domain A that is on that domain where sharepoint server is installed. Still same error getting at clientContext.ExecuteQuery();. I dont know why pelase help.

Please help.

Thanks in advance

  • What type of authentication you are employing within the target web application on Domain A? And does the SharePoint server on Domain A know who username is? You may also want to see: sharepoint.stackexchange.com/questions/35933/… Commented Jan 4, 2013 at 5:30
  • NTLM windows authentication and our sharepoint server is on Domain A and yes the credentials which i am using are already exist on Doamin A means on Sharepoint server
    – RL89
    Commented Jan 4, 2013 at 5:37

3 Answers 3


Can you access the SharePoint library with your browser when you use the user? If so then this could be doublehop issue;

"The double-hop problem will usually only be an issue to those of you who write some sort of web-based code (a web application or web service) that uses impersonation."

I´m probably the least capable person to work with code but I would like you to try out the browser with the user and see what happens. EDIT:


  • 1
    Hi Funi! Can you please clarify in your post where that quote is from? :) Commented Jan 2, 2014 at 20:02
  • Fixed. Noted for future posts. :) Commented Jan 2, 2014 at 20:06
  • Great! It is easy to forget, but it is nice to give people credit for their contributions :) Commented Jan 2, 2014 at 20:08

You can and its called cross domain access that you would need to setup on the server, this is a link to another question with the answer:


hope it helps :)

  • I transfered my machine to same domain but still getting the same error.
    – RL89
    Commented Jan 4, 2013 at 9:30

Make sure the credentials you're passing match the destination farm's authentication mechanism - classic/claims (assuming this is 2010).

Also try using the Secure Store Service Application to host your connection credential settings.

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.