4

I can access Sharepoint list using JSOM from local SharePoint site. In the same place I also want to access SharePoint list from a different SharePoint server.

What is the best way to do this?

I want to write all my code on a button click.

Scenario:

On success, get data from current list and post same data to a list on another Sharepoint site with different AD.

4

If you have enough permissions on the source and destination lists you can either use Managed CSOM from a console application or JavaScript CSOM from any web page to achieve this.

if you are running the code from the same active directory (AD) of source list or destination list and you have enough permissions on both the lists you got to pass the credentials to either source or destination where you doesn't have permissions using the following code and move on.

using (ClientContext context = new ClientContext("http://someserver/")) {
    context.Credentials = new NetworkCredential("user", "password", "domain");
    List list = context.Web.Lists.GetByTitle("Some List");
    context.ExecuteQuery();

}

Let me know if you have any questions.

  • I want to use Javascript CSOM. do I have to create app for this ? as I want simple calls to the cross domain Sharepoint list. Just like I have CSOM calls for accessing list from local SharePoint site. – Muhammad zaighum Jun 29 '15 at 5:47
  • @Naveen As Zaighum mentioned that the lists are in different AD, a simple client side call won't work.:/ – Taran Goel Jun 29 '15 at 6:15
  • Taran, I have updated my answer for you with more clear instructions. – Naveen Jun 29 '15 at 8:34
  • 1
    I used C# and was able to access lists from different domain. – Muhammad zaighum Jul 7 '15 at 9:53
1

As Client Side object model runs with the current user credentials and you mentioned that the farms are on different AD's altogether. You'll need to manually provide some credentials who have access to the farm from which data needs to fetched. Either you can ask the user for credentials in a popup or you can manually give them (Security Risk). Cross Site would have possible but having a list in different AD is bit of a task to handle. If possible you can also make the source list public so that users in other site can consume it through web service but it all depends on the type of restrictions you want to maintain.

  • do you know any sample code for above scenario? like accessing remote lists and asking user for password – Muhammad zaighum Jun 29 '15 at 6:17
  • What type of restrictions you want to maintain? The easiest solution is to give anonymous access to the source list but if you can update your question with the restriction I'll be better able to answer. – Taran Goel Jun 29 '15 at 6:33
  • I just want to access remote list and add items in it. I cannot make it public for editing – Muhammad zaighum Jun 29 '15 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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