tags:

views:

1045

answers:

4

I'm trying to get an SPSite for a remote SharePoint URL:

SPSite site = new SPSite("http://remoteserver");

...but I get an exception. The is no problem when i try to connect to sharepoint on the local machine.

I have the required username and password of the remote server. Is there a way to get the SPSite with the username and password?

+4  A: 

You cannot do this from a remote machine. You will have to either be running that code on the SharePoint server machine, or interact with the remote server via the SharePoint web services that are exposed.

Can you be more specific about what you want to do with the SPSite once you get it? This may make it easier to make a judgment about which techniques are more appropriate for you.


Since you say you want to interact with lists on this remote site, I suggest you look into the Lists web service that comes with SharePoint 2007 and WSS 3. This SO question is similar, and there's a link to some resources there:

http://stackoverflow.com/questions/1711176/how-do-i-update-a-sharepoint-list-using-net

Chris Farmer
I want to get an item in the List.do you know how to do this programmatically from the remote machine or could u give mi some good links on this topic
CoffeeCode
Fortunatley, this scenario has been fixed in SharePoint 2010. There is a new client API that lets you connect to remote sites. At last!!! Here's a simple overview of the object model http://www.chakkaradeep.com/post/SharePoint-2010-Introducing-the-Client-Object-Model.aspx
Jason Evans
Check out here also http://msdn.microsoft.com/en-us/library/ee535231(office.14).aspx
Jason Evans
+3  A: 

You'll need to use the OOTB Lists Data Retrieval web service to retrieve list data from a remote machine. The SharePoint object model can only be used on the SharePoint server itself.

OedipusPrime
+1  A: 

As the previous answers said, either you use the sharepoint web services, or you use the code you have and create a custom web service on your sharepoint environment and call it from your external application.

KoenVosters
+1  A: 

Actually you could connect to a remote site if you have SA on the underlying SQL server. Just use SPFarm.Open(). I'm not saying it is optimal, just making sure it is out there.

unclepaul84