I have a SharePoint Farm with 25 servers. I was asked to build a new server out of the SharePoint to pull the information from SharePoint Farm and store in SQL Server in different server outside of the SharePoint Farm within the Same network. I will need to use to C# and SQL Server to pull the information from remote SharePoint Farm. I have already installed SharePoint in my local development box. How do I connect to remote SharePoint Farm with C#. I have the Farm Administrator User Credentials. How do I connect to the SharePoint Farm wihtout being in the actual Farm with C# or with PowerShell?
2 Answers
You should use Client Object Model (.NET Framework redistributable assemblies):
http://msdn.microsoft.com/en-us/library/office/fp179912(v=office.15).aspx
You need to reference SharePoint client DLLs into your remote VS project:
- C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Client.dll
- C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Client.Runtime.dll
(replace "14" by "15" in these paths if SP2013)
These DLLs are redistribuable (can be deployed with your Web site or exe) and can be used on a development machine without SharePoint installed.
Once these DLLs are referenced, you can write C# code to access/manage your remote SharePoint. Examples can be found in the MSDN, for instance, to read list items: http://msdn.microsoft.com/en-us/library/office/ee534956(v=office.14).aspx (SP 2010, same for SP2013).
Note: these client DLLs are wrappers around SP Web services and REST calls. So, a simple HTTP(S) connection is required between the client and SharePoint.