SharePoint 2010: How to Launch Remote Desktop Client from SharePoint

English:

SharePoint document library has widely used to store Microsoft Office document such as MS Word, MS Excel or MS PowerPoint. It provides seamless integration with Microsoft Office client, in which it will launch appropriate client’s application. For example, if the user clicks *.doc file ; SharePoint client technology will detect and try to launch MS Word application. When the user try to edit document, it also try to launch MS Word application in edit mode. If the client doesn’t have Microsoft Office application installed, then SharePoint will offer file download.

How about launching Remote Desktop Client from SharePoint document library? By default, SharePoint does not support client’s integration for *.rdp file. To provide client’s integration for *.rdp file, we must understand how does client integration in SharePoint happen. Then we will use the same principal, so that we will be able to launch remote desktop client from SharePoint.

How does the integration happen?

Thanks to OpenDocument control, an ActiveX control which is pre-distributed during Microsoft Office client installation. This control is defined in OWSSUPP.dll file. The file is installed in the %ProgramFiles%\Microsoft Office\Office14\ directory on the client computer during Microsoft Office setup.

On the server side, SharePoint uses definition in docicon.xml to know appropriate ActiveX control for a specific file type. Then it sends JavaScript script to client’s browser (part of core.js). The script will detects ActiveX control availability in client’s computer and then enable or disable action related to it.

image

Problem Using Custom OpenDocument to Handle File

We can create custom OpenDocument to handle any type of file. However there are some prerequisites before you can use custom OpenDocument in SharePoint:

  1. Custom OpenDocument must implement standard OpenDocument public method members. For more information about OpenDocument public method members, please open technical documentation page here : http://msdn.microsoft.com/en-us/library/cc264316.aspx.
  2. Custom OpenDocument must be distributed and registered in client’s computer environment. You can use *.cab file to package and distribute the control. For more information about ActiveX packaging, please open technical documentation page here : http://msdn.microsoft.com/en-us/library/aa751974(v=vs.85).aspx.aspx”).
  3. Register the new file type and ActiveX control name in docicon.xml, so that SharePoint will be able to create appropriate JavaScript parameter.

Having those pre-requisites, non-compliant ActiiveX control will not ready for client’s integration. On the other hand, there are lot of ActiveX control that does not necessarily follow the standard OpenDocument, thus creating a compliant ActiveX control for client’s integration become impractical.

The Solution

The solution, actually lies on the client JavaScript and ActiveX control. SharePoint must be able to generate client script dynamically based on the registered file type. The script will run on client’s environment, detecting ActiveX control and launch the application. For this purpose we can use custom HttpHandler in addition to original core.js. The HttpHandler will generate client’s script and construct ActiveX detection and execution. Since the script is generated by our HttpHandler, then it is possible to make a call to non-compliant ActiveX control. Moreover, this approach relies on existing ActiveX control on client’s machine so we do not need to distribute new ActiveX control.

image

Launching Remote Desktop Client from SharePoint

For this purpose, I will create RdpHttpHandler.cs that implement IHttpAsyncHandler. IHttpAsyncHandler is asynchronous HttpHandler interface to create more scalable HttpHandler. This class, basically will generate appropriate JavaScript to launch RDP client. It also provides *.rdp file stream, to answer client with no RDP client ActiveX enabled.

Finally, we have to register the handler in web.config.


    
       
            
       

    

To register in web.config, I use SPWebConfigModification from SharePoint API which will be triggered by feature activation event. The feature is web scoped feature, so that you can activate it from Central Administration for specific web application.

Code and WSP Download

Complete working code and solution file can be downloaded from Microsoft website here (RDPViewer SharePoint Solution).

Avatar
Riwut Libinuko
Sr. Cloud Solution Architect

My research interests include distributed robotics, mobile computing and programmable matter.

comments powered by Disqus

Related