Archive for month: November, 2013

SharePoint 2013 Search Preview for Documents hosted in SharePoint 2010

22 Nov 2013
November 22, 2013

Recently I talked to some clients because of a “Search-First” SharePoint 2013 migration (more about this topic will follow). During a training this week I got aware of a serious issue with the “Search-first” approach, especially with the really nice Office Web Apps 2013 Search Previews you get for free (read only!).

Problem

Some clients want to start their migration with setting up a new SharePoint 2013 farm. This new farm then crawls the old SharePoint 2010 farm. After successfully crawling it, the SharePoint 2013 farm then publishes its Search Service to the SharePoint 2010 farm. So far so good. But what happens with all the new shiny features in the Search UI? Nothing. Until now everything works as it should – you now get better search results in your existing SharePoint 2010 environment.

Now let’s take it a step further. Replace the SharePoint 2010 Search Center with a Search Center hosted in SharePoint 2013 – replacing is actually wrong, you have to do a redirect from the SharePoint 2010 environment to the Search Center in SharePoint 2013 – with the Search Preview, Display Templates and all the good stuff. Pretty great, I totally love the new features and the business value you can create with it:

SharePoint 2013 Preview of PowerPoint document hosted in SharePoint 2013

SharePoint 2013 Preview of PowerPoint document hosted in SharePoint 2013

But here is the Problem: You crawled the SharePoint 2010 environment – by default you wont get a Preview for documents in the old environment:

Preview of a document hosted in SharePoint 2010

Preview of a document hosted in SharePoint 2010

There is a great article by Murad Sæter how you could substitute the Preview with Office Web Apps 2010 (the service application in SharePoint 2010 that needs expensive Office 2010 licenses!). Many of my clients don’t have the Office 2010 licenses – many of them still use Office 2007 – so a show stopper. PDF Preview with old Office Web Apps – nope. This additionally applies to documents hosted on a fileshare – that does not work either.

Reason

So we have Security Trimming in SharePoint Search – you only see what you are allowed to see. Why is there now Preview?

Thats because of oAuth – or better the inability of SharePoint 2010 to understand and accept oAuth (great explanation here by Kirk Ewans).

Behind the scenes

The following happens when you hover over search result that is suitable for a Preview – let’s name the searching user Max:

  1. The search crawler created a link to render a document in the browser. This link is stored in the property ServerRedirectedURL or ServerRedirectedEmbedURL.
  2. This link points to a SharePoint Page called WopiFrame (e.g. http://sharepoint2013/_layouts/15/WopiFrame.aspx?sourcedoc=/Documents/OSP218.pptx&action=default&DefaultItemOpen=1)
  3. This WopiFrame page knows the url to the bound Office Web Apps Server and redirects the request to it. With three parameters: The sourcedoc of the document to render, an oAuth access token and an oAuth time to live token.
  4. The Office Web Apps server, in order to render the document and deliver it back, needs the document to render – of course. Because we left the original server where Max was authenticated – we don’t have this client context anymore – the request from the Office Web Apps back to the SharePoint 2013 server to get the document is anonymously. But why does the SharePoint delivers our precious document? Thats because of the oAuth access token – SharePoint 2013 can validate it and accepts the request like one Max would actually do.
  5. After some computing and drawing time, the Office Web Apps server delivers the preview back to Max.

Because SharePoint 2010 does not understand and accept anonymously requests (most of the time) – and does not understand oAuth tokens – Office Web Apps 2013 do not render Documents hosted on SharePoint 2010.

 Solution: SharePoint 2013 Search Preview for Documents hosted in SharePoint 2010

Figuring out a solution cost me 4 days “brain time” – thinking about the problem – understand the root cause – analyzing options. And chatting with some really nice guys – more about this later.

In the following picture I show you the flow how the requests go from one server to another:

Flow of the requests to render a document hosted in SharePoint 2010

Flow of the requests to render a document hosted in SharePoint 2010

In order to make this all happen, I created a SharePoint Farm Solution (full trust) that needs to be deployed on the SharePoint 2013 side. This provides two handlers that do the following.

SP2010Redirect.ashx: Accepts the initial user request and generates a url that contains the document that should be rendered (full url), the requesting user (domain login) and a simple hash (prevents tampering with the data – no real security!) – that guy is for step (1) in the flow.

SP2010Preview.ashx: Accepts the request back from the Office Web Apps server with the full url of the document, the user login and the hash. With those three values it can check the integrity of the parameters, download the document of the SharePoint 2010 (or what system you like) and  returns it to the Office Web Apps server. This page handles step (3) to step (6).

Pictures / Video or it did not happen!

 

Working Preview of Document hosted in SharePoint 2010

Working Preview of Document hosted in SharePoint 2010

Flaws of the current implementation /

Room for improvement

The code I am going to share is no production ready code – there are magic, hard-coded values in it. I only demonstrate how I did it. No warranties for what so ever.

So why don’t I use oAuth and the WOPIFrame for all the security stuff? Thats because of wonderful internal classes. Dear Microsoft – please open up so I can implement a secure approach.  If I miss a thing and can actually use oAuth directly – please let me know!

Again in other words: If you can create the hash that is passed along for anti-tampering, the SP2010Preview.ashx will download you every document of the SP2010 (this is serious!!) – in my code I did not implement the security check for the given user anyways 🙂 Neither did I add the display template – but its so easy to change it, you will figure it out.

Grab the demo code here.

Thanks!

I really love the SharePoint community – there are a lot of helpful and awesome guys out there. To quote a few that really helped me figuring out this solution:

 

Converting a Hyper-V VHD to VHDX – and shrink it

12 Nov 2013
November 12, 2013

Yesterday I thought its time to convert my SharePoint 2010 development environment Hyper-V vhd to a new vhdx.

Why bother?

I used my environment hosted on my lovely Lenovo W520 to develop a migration tool to convert a SP2007 environment to a SP2010 environment. Therefore I needed ~300GB free space – easy with Hyper-V. Just extend your virtual drive and you are good to go. Afterwards you can easily shrink the disk back again – at least I thought so. But, no  – the Hyper-V wizard could not shrink my virtual disk after project finish. There were unmovable files – bummer. So I thought lets delay this for until… yesterday.

Why now?

The week before I read about the new Hyper-V Generation 2 VMs – pretty good stuff. No emulated drivers – direct access to the Hosts disk drives, sounds like a SharePoint would love it. And I migrated my work PC to Windows 8.1 – this is a requirement.

How I finally made it?

To convert a vhd to a vhdx just open the Hyper-V Manager – open the properties of a VM, go to disk settings and click on convert. Then choose vhdx and on the very last page a location with sufficient space.

Open the disk settings

 

Select convert

select vhdx

My location was on a usb 2.0 drive – apparently I had no 300GB space left on my SSD. So the whole converting took me roughly 3 hours. Then I tried to boot the converted VM – worked. Deleted the old vhd file and copied the new vhdx back. Another 3 hours.

Now the shrinking part, right?

Okay I thought – Windows Server 2008 R2 should be capable of this – theoretically yes. But there were unmovable files detected – defrag could not move them. I tried everything. Inside and outside of the VM, nothing worked. The explorer showed me 100GB used, 200GB free space – but still 300GB on my host’s ssd.

SSD space is expensive!

So after some research I found a nice tool called Paragon Partition Manager 2013 (apparently I do not get money from them – I am not related!). With the free edition I could resize my mounted vmdx – took like 10 minutes. Love it.

Reclaimed 180GB precious space on my ssd

Whats next?

Tomorrow I will convert my SP2013 hosted in a Windows Server 2012 into a generation 2 VM – then I will truly see the new performance. Generation 2 is only supported with Windows Server 2012 (& R2) and Windows 8 + 8.1.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close