I'm new to the SharePoint 2013 .Net Client API. I want to programmatically crawl all of a SharePoint site. I want to fully extract lists, document, pages, everything!
Ideally I want to start with the root of the website and crawl everything from there.
Can someone give a high-level overview of the basic steps involved? For example, do I need to create a catalog, or can I simply crawl if I have the admin credentials?
I'm using C#, .Net 4.0, and the Client runtime API (not REST).
Some of the links that were helpful for me :
1. Crawling with Rest API or PowerShell - Start a crawl manually via SOAP or REST WebService
2. Recrawling using code - http://sebastian.expert/force-web-whole-list-library-re-crawled-search-sharepoint-2013-using-api/
I believe that everything in SharePoint lives under a List. Essentially, I fetch the Lists belonging to a Web and fetch all the ListItems from those. I ignore Folder and File collections as these are duplicates.
Related
I am currently developing an application using Sharepoint 2010 Web services to access data from a Sharepoint server. Im using ListData.svc to get items of a particular list of documents saved in the SP server, and my aim is to be able to search through this list, including its documents contents. I have been researching through options, and have seen stuff like asmx, enterprise search API, query services, etc., but I am not quite sure if this would really crawl through the file contents.
Can you enlighten me on what web service to use to be able to search through a particular list of files-- all its properties and file contents? Similar to the search option in an actual Sharepoint site?
Thanks!
Id expect a quick google on "Sharepoint 2010 search api" to yield up https://msdn.microsoft.com/en-us/library/office/websvcspsearch(v=office.14).aspx which says "Search in Microsoft SharePoint Foundation 2010 exposes its search functionalities through the Query Web service. This allows you to access SharePoint Foundation Search results from client applications and Web applications outside of the context of a SharePoint site."
I guess if you read those docs, the solution will be in there.
I have two sites - old and new one.
The newest is Sharepoint 2010 portal. Several part of it are under construction and when user requests site which is under construction I need to return page from old portal.
I've found an article which describes how to implement Sharepoint 2010 reverse proxy using URL Revrite and Application Request Routing.
But URL to old site should contain a dinamically generated parameter.
Is this possible to interfere in Sharepoint or IIS working process to generate this parameter and change dynamically this URL address before it will be processed?
HttpModule will allow you to run some codez inside HttpRequest processor, but I'm not really sure you wanna go that route...
I'd like to fetch some files from a SharePoint site, however I do not want to use the web services as a) I want to be compatible with both 2007 and 2010 and b) I'm not sure if Web Services can give me all files on a site.
SharePoint Designer can do that, and it seems to use FrontPage Server Extensions using _vti_bin/Author.dll. Also, I can access it in Windows using Map Network Drive -> Map Web Site, which I think is using WebDAV.
Is there any C# implementation of either a WebDAV Client or a Author.dll Client?
You could change this code to download. http://geek.hubkey.com/2007/10/upload-file-to-sharepoint-document.html. Just search around for different upload code and mess with it. I would give you my code for uploading files but I am on vacation and I promised myself that I would not log into work :). That link should get you pointed in the right direction.
I am working on project where I have to access SharePoint data in C#.
I've never done this before; and have the following questions?
How would I access SharePoint data from C#? What API do I use? Are there any tutorials out there that will help me get started?
There two ways in which you can access Sharepoint data:
By Using Microsoft.Sharepoint.dll
In this case you need to do coding on same machine (windows server).
Second way is to use Sharepoint Web Services.
This will allow developer to do developement work on different machine.
The SDK is a good place to start. The real crux of question lies in whether you are writing code which will live in a SharePoint environment, or writing code which will consume SharePoint data in an external application.
In the case of the former, SharePoint has its own API which you gain access to by simply referencing the appropriate DLL.
For the latter, SharePoint comes with a set of web services which allow external applications to consume its data. Either these or a set of custom services (running in the SharePoint environment) will be your entry point into SharePoint.
This is how you would do it in PowerShell which is very similar in how you would do it in in C#:
# Lets reference the assembly / GAC that we need for this
function getUsers
{
param ([string] $verify_sitepath="https://extranet.something.com")
$verify_site=new-object Microsoft.SharePoint.SPSite($verify_sitepath)
$verify_web=$verify_site.Rootweb
$verify_web.site.url
$verify_groups = $verify_web.groups | ? {$_.Name -match "^.*$CurrentGroup" }
foreach($verify_group in $verify_groups)
{
foreach($verify_user in $verify_group.users)
{
$verify_user = $verify_user -replace "WRKGRP\\",""
Write-Output "$verify_user" | Out-File -filepath "$splist$currentGroup.txt" -append
}
}
}
What this does is gets all the users from SharePoint that are in a text file. Hopefully this gets you at least thinking about how SharePoint is set up.
A great resource is the MSDN page with all the functions. They provide a lot of programming samples in C#!
Start at the Sharepoint SDK page. Download the SDK, and look at the sample code on MSDN.
Added later: according to MS, this is a better site for all things related to Sharepoint development.
You have to install VS 2005 or VS 2008 extensions for sharepoint. Intsllaing them on xp can be tricky and this page should hep you with that.
you should also CAML Query which you should know to query data from sharepoint lists
you can make use of such a tool http://www.u2u.be/Res/Tools/CamlQueryBuilder.aspx
To me it sounds like you should use the Out Of The Box SharePoint web services. There is no reason why you should have to learn the entire SharePoint API when you could get along just talking to the web service.
This primer on InfoQ is good, but do a seach on SharePoint Web Services and you will find plenty of sources
I have a standard ASP.NET 2.0 website.
It has a webpage page.
I have a webpart in my Company.Web.dll that I display on my webpart page on my website.All is good!!!
I would like to use this same webpart in SharePoint 2007.
I have a "site definition" project in VS2008 using Extensions for SharePoint 1.2. I have tried various ways to add the webpart from an outside assembly to my site definition. I have been able to deploy the webpart (where it is added to the webpart list of a webpart page) but I have been unsuccessful at adding the it to a page.
My Glorious Failures:
Created a shell webpart to just display the existing web part, basically just using my part as a control.
Attempted to modify the X.webpart and X.xml files created by VS2008 when you create a new webpart.
Both result in the following error while adding the web part to the page:
Exception
Microsoft.SharePoint.WebPartPages.WebPartPageUserException:
Cannot import XXXX Web Part.
at Microsoft.SharePoint.WebPartPages.WebPartImporter.CreateWebPart(Boolean
clearConnections) at
Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager
manager, XmlReader reader, Boolean
clearConnections, Uri webPartPageUri,
SPWeb spWeb) at
Microsoft.SharePoint.WebPartPages.WebPartImporter.Import(SPWebPartManager
manager, XmlReader reader, Boolean
clearConnections, SPWeb spWeb) at
Microsoft.SharePoint.WebPartPages.WebPartQuickAdd.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
Is there a special way I need to add my existing webpart to my site definition?
This sounds like a problem resolving the GUID at deployment time, as you can read about in this SO question.
To find the details of why the web part won't import, check the ULS logs. These are typically located at %CommonProgramFiles%\Microsoft Shared\web server extensions\12\LOGS. An entry will be logged here at the time you attempt to add the web part to the page. This should give you more detail.
My guess is that it is a code access security issue. Your web part must be strongly signed and needs a SafeControl entry in the web.config of the SharePoint web application. Apart from these things you should be able to just add it to the Global Assembly Cache to test if it works (best practice is to write a CAS policy file). See Deploying Web Parts in Windows SharePoint Services for more details.
I would try these steps before trying to integrate it as part of a site definition. Then at least you know the web part will actually run.
Also, VSeWSS is really designed for developing your web part using it from the very start. If you have the original source, you could try creating a new web part with VSeWSS and then replace with your custom code and update the .webpart and feature XML files. Then it should behave a little better. If you haven't committed to VSeWSS, try WSPBuilder as it's less painful.
ASP.NET webparts and Sharepoint Webparts are NOT the same. You should be able to use a ASPNET webpart within Sharepoint. See the following table:
ASP.NET 2.0 Web Part
For most business needs.
To distribute your Web Part to sites that run ASP.NET 2.0 or SharePoint sites.
When you want to reuse one or more Web Parts created for ASP.NET 2.0 sites on SharePoint sites.
To use data or functionality provided by Windows SharePoint Services 3.0. For example, you are creating a a Web Part that works with site or list data.
SharePoint-based Web Part
When you want to migrate a set of Web Parts using the SharePoint-based Web Part infrastructure to Windows SharePoint Services 3.0.
To create cross page connections.
To create connections between Web Parts that are outside of a Web Part zone.
To work with client-side connections (Web Part Page Services Component).
To use a data-caching infrastructure that allows caching to the content database.
For a Sharepoint webpart to work in a standard ASPNET application you would need to recreate your webparts in Visual Studio (as an ASPNET webpart) without the Sharepoint 2007 references for it to work correctly.
One nifty tool which I have used in the past is the SmartPart Worth checking out:
This lets you create a ASP.NET usercontrol (visually) in Visual Studio and then host this in Sharepoint. The smartpart acts as a wrapper wepart for your user control. Think of it like the page viewer webpart in Sharepoint except instead of it being HTML pages its ASP.NET UserControls.
You would need WSS 3.0, SharePoint MOSS or 2007 to use ASP.NET 2.0 WebParts. SharePoint 2003 or below and WSS 2.0 or below do not support ASP.NET WebParts.