tags:

views:

268

answers:

4

Hi,

Can anyone tell me if I have some ways to access to sharepoint list from windows app?

I've tryed following way (i'm under user that is sharepoint member):

SPUserToken token = new SPUserToken(
            BitConverter.GetBytes(WindowsIdentity.GetCurrent().Token.ToInt32()));
SPSite site = new SPSite(siteName, token);

but no luck...

A: 

Hi there.

Is siteName on the same computer that you are running the windows application from? If not, then you won't be able to access that site if you're using SharePoint 2007.

If the above isn't the problem, then check that the user account WindowsIdentity.GetCurrent() is at least a site owner on siteName.

Cheers. Jas.

Jason Evans
+2  A: 

Your best bet is to use a web reference to query the SharePoint WebService's GetListItems web method:

http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems.aspx

Dylan Berry
+1  A: 

Like Jason said, to be able to use the SharePoint Object model (i.e. the sharepoint dll's) the app needs to be running on the same machine as SharePoint. If it is anywhere else you can only use the Web Services provided by SharePoint (or create your own and deploy that to your sharepoint server).

P.S. In SharePoint 2010 you have the client object model at your disposal, basically a subset of the full sharepoint object model (Kinda like Silverlight). Of course sp2010 is still in beta....

Colin
+1  A: 

This article provides an excellent and detailed step by step tutorial on how to do this using Linq and Web services. It does create a console application instead of a Windows application but it is very easy to translate this into a Windows Form app if needed. I found this article very useful when I started working on programatically communicating with SharePoint lists because it clearly demonstrates how easy it is to work with the web service response from SharePoint using LINQ.

SnapShot
seems, link you posted above is wrong. Could You give me correct link please?
Zim
Sorry about that - I am new to Stack Overflow. I have corrected the link now.
SnapShot