Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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);
clientContext.ExecuteQuery();

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.

Update

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

share|improve this question
    
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/… –  nsturdivant Jan 4 '13 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 –  Rahul Jan 4 '13 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:

http://blogs.msdn.com/b/knowledgecast/archive/2007/01/31/the-double-hop-problem.aspx

share|improve this answer
1  
Hi Funi! Can you please clarify in your post where that quote is from? :) –  Robert Lindgren Jan 2 at 20:02
    
Fixed. Noted for future posts. :) –  Funi Magnússon Jan 2 at 20:06
    
Great! It is easy to forget, but it is nice to give people credit for their contributions :) –  Robert Lindgren Jan 2 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:

http://stackoverflow.com/questions/12780886/cross-domain-access-in-sharepoint-2010

hope it helps :)

share|improve this answer
    
I transfered my machine to same domain but still getting the same error. –  Rahul Jan 4 '13 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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