1

We have requirement to move /copy documents from one site to another, sites are on different farms( totally different environment). We can can copy items if library in same application/ site collection using SharePoint Workflows. One option could be using REST API, but when i tried to use this approach i am getting 'Cross Server Access Denied issue'. And i want to implement this functionality as like event receivers , whenever any item updated/added with information to update in Partner's site. Please advice, thanks.

2 Answers 2

0

If you open the library in explorer mode on both farms, you can copy files from one farm to the other just using regular windows operations. Beware though that version history won't be copied. To make that happen you need to move documents using a 32-bit version of Internet Explorer from which you open the explorer window.

But if you have a lot of documents, this method is time consuming - and you'd probably want to download documents with PowerShell and in the destination farm, upload the documents again.

1
  • This require manual effort and we need a programmed solution. Commented Oct 3, 2016 at 6:37
0

In your event receiver method, You can write code in Managed CSOM to connect another farm with different credential.

using (ClientContext ctx = new ClientContext("site Url on different farm"))
    {
       SecureString password = new SecureString();
       foreach (char c in "paaword@123".ToCharArray())
       password.AppendChar(c);
       ctx.Credentials = new SharePointOnlineCredentials("useremail", password);

      //write your code in Managed CSOM to move file to another farm
    }
1
  • I tried this, getting save conflict error and how i can attach file inside event receiver. WebClient client = new WebClient(); client.Credentials = new NetworkCredential("Administrator", "Unisys@3345", "V3DEVSP"); Stream stream = client.OpenRead(srcUrl + "/" + properties.AfterUrl.ToString()); StreamReader reader = new StreamReader(stream); String content = reader.ReadToEnd(); Commented Oct 25, 2016 at 7:45

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.