- December
- 9
- 2008
Developing a Deployable App to Access SharePoint Information – Part One
Posted by jeff102410
No Comments »
The Disclaimer…
OK, I may be totally missing something, but I have not been able to use the SharePoint Object Model to access a SharePoint site not located on the same machine that the code was running on. If I missed the way to do this, then please let me know. The rest of what follows is based on the fact that I have to develop/test/run any programming that I create on the production machine.
The Problem…
For a couple of years, I have not been able to successfully use the SPSite(http://URL) on a development machine and have the SPSite actually open the site on another machine. For example, my workstation opening the group beta/testing site. I generally get a FileNotFoundException error. I have researched this at length…for a very long time…without any success. I find some posts talking about setting security on the site app pool, network services or local services not having proper access, and all kinds of other things…but nothing really useful.
The Research…
Today…after looking through literally hundreds of sites, I found a couple of "mentions" about SPSite that were useful. Both of the posts "mentioned" in passing that SPSite will only instantiate properly to the localhost. Finally…someone with the same conclusion that I had reached.
It's just my opinion…and not based on anything else…but here is the problem. SharePoint will not allow access to anything without proper authorization. SPSite tries to get to the site without proper authorization. The catch 22 here is that you can use SPSite with a user token, but the user token can only be created once the SPSite object is created. SPSite works with localhost because the local credentials used to access windows are used by SharePoint during the SPSite instantiation. When going to a non-localhost machine, the local credentials cannot be used and the user information is null. There is no overload method to SPSite to pass userID/password….and I cannot find anything that can be done to get around this…
The Solution…
At least the solution I have come to…
All of the problem is based on using the SharePoint Object Model. Once I got outside of the SharePoint Object Model box, the alternative is to use SharePoint Web Services. And yes, in less than an hour, I'm opening the SharePoint site on a different machine, getting the list of sub-webs from the root web, and displaying the list in a datagrid…100 percent windows app…getting SharePoint site information.
I'll post the code and details in Part Two…