Search for Sharepoint 2010

Search has got a whole lot bigger, you don’t need to look at google or MSFT to see that. Search has exploded in the past 10 years and one of the fantastic bi-products of the explosion is search for sharepoint 2010. Learning from all its mistakes in 2003, 2007 and online Sharepoint Search now trumps all other intranet search engines we have seen. Federated search zones, scanning and crawling almost everywhere, separated search centres, damn microsoft has search down in sharepoint 2010.

Our biggest win with search in microsoft sharepoint 2010 is the search centers, you can deploy them just like any other sharepoint website, under any other site (blank or publishing site) and you can give them scope’s, customise them specifically and tailor them uniquely. This is a big win in multi-stakeholder environments because you can have a search specific to each stakeholder, with a different look, feel and access rights. Fantastic.

The MOSS search service is also slick, it’ll chomp up resources in the course of crawling but its very slick. Incremental searches after the initial crawl will do in most cases and with its split database its easy to see how quick your organisations digital estate grows if you set a search service crawling everything. And it will search EVERYTHING – you can set it to search shared network drives for files, external websites, internal websites, other sharepoint site installs just for starters.

There is so much more to the sharepoint search in 2010 that we will probably do a complete setup guide for search in MOSS 2010 at some point – but just believe it is fantastic once you get it all setup. Accessing it via Csharp is also easy and effective. Congrats Microsoft, congrats.

Sharepoint Virtual PC – Sharepoint Development Environment

If you are developing for sharepoint you have likely come across the stumbling block. Your running something like Windows 7, Vista or XP, Visual studio 2008, 2010 something like that. You want to develop for sharepoint directly but when you go to make a fresh webpart or indeed any solution for sharepoint it basically says “No sorry, you need to have sharepoint installed.” This is a mighty pain for development.

Now you can do transplant coding, in that you reference directly the DLL’s ripped from the Microsoft sharepoint installation elsewhere, and code that way – this works for master pages, migration and other independent projects – but if you want the ability to deploy to a server, or in fact to work with web part solutions/projects then you will need at least a faux install of sharepoint.

We will go into more detail about the process in a later post but there are several options you have when you get to this point:

1. Hack around the Sharepoint installation of sharepoint foundation to make it install on windows 7/vista.
For us this didn’t work as well as it has for some people, but we have seen it working and it does get the best of both worlds – 7 is great for developing in, quick etc – but it can be a pig to make it install. Microsoft themselves advise this – there is this guide which walks you through hacking their sharepoint foundation install to work on 7/vista, which says a lot about the state of play for developing (properly) for sharepoint, that MSFT themselves are hacking around their stuff to make it work.

2. Virtual PC Sharepoint install
This is the most likely option to work out of the box. The premise is you setup a decent virtual box (on your dev machine or on a pooled virtual hardware resource if you have one) on windows server (2008 r2?) and install sharepoint (2010?) and Visual studio (2010?) Then develop on this box, which has both advantages and disadvantages. Benefits include a developer local instance of sharepoint – so you can test things in their own environment without breaking sharepoint (although 2010 sharepoint deals with segregating solutions quite well anyway) and it is also nice to be able to snapshot and move your dev box in one single file. Downsides however are numerous: How much power can you actually give to a virtual box? Yes you can get multiple screens, give it 70% of your pc’s resources or whatever but it will still be a windows server box, run virtually – so don’t expect the fantasticness of 7. The biggest thing to think about with this is the extra licenses. Legally you may require another Visual studio licence, another windows server licence and you can use sharepoint foundation so that should be ok.

3. Develop On Server
Lastly you can always just develop directly on one of the farm server’s – although this has associated risk. Crash your machine? yep you took out sharepoint (or one server at least), abusing the processing to test something? yeah thats abusing the sharepoints processing resource.

There is no right way of doing this at the moment then really, Virtual pc developing sharepoint works, but its dirty and potentially more expensive, I am sure this will get better though, as MSFT seem to be getting much better at this stuff.

The search service is not able to connect to the machine that hosts the administration component. Verify that the administration component ‘s0meAppID-Here3-3fsdf3ef33425′ in search application ‘Search Service Application’ is in a good state and try again

“The search service is not able to connect to the machine that hosts the administration component. Verify that the administration component ‘s0meAppID-Here3-3fsdf3ef33425′ in search application ‘Search Service Application’ is in a good state and try again”

Ever see this? In a strait up install of sharepoint 2010 it’s not surprising to see several of these errors, they take a few different forms but mostly its moaning about administration components. In short what this is likely to be if you see it is that the services needed for a given sharepoint 2010 farm/site feature to run are not running.

This can happen for several reasons:

Permissions/User Accounts
If your running a simple 3 box farm (or 2 box) and you are confident the boxes can see each other properly then its likely to be rights/permissions. That is the user or application pool set up for the required service/machine application has too little rights (or in fact too much!)
The error’s (depending on where in central administration you find them) can be counter intuitive. If you are having problems getting sharepoint service applications running firstly make SURE you understand which is running on what user account, app pool and that that user has the correct rights. Setting all of the app pools to run as administrator, and all of the windows services likewise is also not the solution (while it may fix it short term) – this opens huge wholes in your security – do you really want any web part/page to run with admin rights?

Server sight
For bigger installs it can be commonly users as above, but also the sight each server has of the others. SSL needs to be set up properly, servers need to be on the same VLAN (or correctly routed.)

We will go more in-depth into some of these issues in time, but for now – check your Service Applications in sharepoint 2010 – do you know which has its own app pools and who they are running as?

Tip: It can be beneficial to give each service application its own app pool and schedule staggered recycling (even across topology)

“Sharepoint 2010″ is..

What is “Sharepoint 2010″ for you? For almost each and every stakeholder you asked that question too in your organisation (if you already have sharepoint) you would get a different answer. If you don’t already have it chances are 90% of people would not even know what “sharepoint 2010″ is. My personal definition for 2010 would be different too 2007 or 2003 or 2001 too, they have improved, refined and added so much at the microsoft camp that I could more certainly say, to me “Sharepoint 2010″ is…

A framework for document management, internal and external employee community and an external facing content management system.

In reality though MOSS, WSS, “Sharepoint 2010″ can be so many things to different people. Its like a transformer mixed with a filing cabinet. For the office lady its her CRM software, for the pr front house people its the CMS which powers the front end website, for your techy people its an ICT helpdesk, for your project managers its a globally available project management suite, for your assitants its a time sheet and for you its a performance dashboard. Sharepoint can be all of this, which perhaps makes it a transformer, a foundation or a combination of these.

“Sharepoint 2010″ ..is… like a transformer mixed with a filing cabinet.

So what is “Sharepoint 2010″ to you? Have you thought about what it means to your stakeholders? do you have a plan for consumers and producers? Tell us – What do you envisage when you read “Sharepoint 2010″?

Upload image directly into Sharepoint Picture Library – CSharp

We have touched on inserting an image directly into a default sharepoint picture library (using csharp and in sharepoint 2010) but what if you want to upload an image directly into Sharepoint 2010, but to a specific gallery? Well the first step is to find the specific guid of a gallery – something you can do by enumerating though the galleries by name or direct reference.

Using the following (and getFileNameFrom Url, GetBytesFromUrl) you can simply through a gallery guid, new image title and an image URL at this and it will grab the image, save it to a sharepoint 2010 gallery with that guid, with the given title. Simples.

//get the parent SPWeb
SPWeb parentSPWeb = homeSite.AllWebs[parentWebUrlStr];

//get the SPList Gallery from a GUID
SPList gallery = parentSPWeb.Lists[galleryGuid];

//add image direct from url
System.Collections.Hashtable imageProperties = new System.Collections.Hashtable();
imageProperties.Add(“title”, “New Image Title”);

//upload image returning SPFile
SPFile imageUploaded = gallery.RootFolder.Files.Add(

getFileNameFromUrl(imgSourceUrl),
GetBytesFromUrl(imgSourceUrl),
imageProperties

);

Sharepoint 2010 Publishing Page Layouts

Its often you want to make a new sharepoint publishing page or to update an existing one strait via code. In csharp, thanks to microsoft’s ever improving sharepoint support this is really easy. One of the key points when updating publishing pages however is getting and setting the right page layout.

You can use code like this to cycle through the available page layouts, this can be the easiest way to find the one you want.

Note: sometimes you need to enumerate to find the right one!

foreach (PageLayout lo in pubweb.GetAvailablePageLayouts())
{

//some code for page layouts

}

…and to set the page layout of a sharepoint 2010 publishingPage in csharp you usually just include it in the edit code. We will post more about this in the future.

Here is the different page layouts (defaults – if you create your own you will have to set a page to use it then use code to find the correct name – or just be sure you know it beforehand) and their sharepoint values – you can use these to programmatically set the layout of a sharepoint 2010 page in csharp (migration code is a prime example.)

(Article Page) with Body Only pagefromdoclayout.aspx
(Article Page) with Image Left articlesleft.aspx
(Article Page) with Image Right articlesright.aspx
(Article Page) with Summary Links articlelinks.aspx
(Redirect Page) Redirect Page redirectpagelayout.aspx
(Welcome Page) Advanced Search advancedsearchlayout.aspx
(Welcome Page) Blank Webparts Page blankwebpartpage.aspx
(Welcome Page) People Search Results Page peoplesearchresults.aspx
(Welcome Page) Search Page searchmain.aspx
(Welcome Page) Search Results Page searchresults.aspx
(Welcome Page) Site Directory Home tabviewpagelayout.aspx
(Welcome Page) Welcome Page with Table of Contents weclometoc.aspx
(Welcome Page) with Summary Links welcomelinks.aspx
(Welcome Page) with Webpart Zones welcomelayout.aspx
(Welcome Page) with Splash Page welcomesplash.aspx