logo

The ConnectWise Control forum has moved to ConnectWise University! This forum has been locked and is in read-only mode. Click here for instructions on how to access the new forum.

Welcome Guest! You can not login or register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Ben B  
#1 Posted : Monday, October 31, 2016 8:41:18 PM(UTC)
Ben B


Rank: Administration

Medals: Level 2: Lent a Helping Hand! 10 Thanks!

Joined: 10/2/2015(UTC)
Posts: 329

Thanks: 1 times
Was thanked: 71 time(s) in 63 post(s)
The following tutorial is based on the contents of the example extension available for download here:
Example: Generate direct session launch URLs.


The Service.ashx file contained in the example defines two methods: GetLaunchUrlFromName and GetLaunchUrlFromSessionID.

GetLaunchUrlFromName takes one string parameter, sessionName, and returns a launch URL for the first session returned by the query or null if the string parameter's value doesn't match at least one session name.

GetLaunchUrlFromSessionID takes one guid parameter, sessionID, and returns a launch URL for the session with that session id or null if the provided guid doesn't match a session id.

You will need to update the following line in Service.ashx to generate a link to download the desired client type (as it is, the generated link will use the ClickOnceDirectHandler to join the session, which only works in IE/Edge):

Code:

var handlerUrl = new Uri(HttpContext.Current.Request.Url, HttpRuntime.AppDomainAppVirtualPath)
    + WebConfigurationManager.GetHandlerPath(typeof(ClickOnceDirectHandler)).ReplaceFirst("*", WebResources.GetString("FileDownload.BaseName"));


To use the ClickOnceRun handler, use the following:

Code:

var handlerUrl = new Uri(HttpContext.Current.Request.Url, HttpRuntime.AppDomainAppVirtualPath)
    + WebConfigurationManager.GetHandlerPath(typeof(ClickOnceRunHandler)).ReplaceFirst("*", WebResources.GetString("FileDownload.BaseName"));


To generate a URL to download the client installer exe, use the following:

Code:

var handlerUrl = new Uri(HttpContext.Current.Request.Url, HttpRuntime.AppDomainAppVirtualPath)
    + WebConfigurationManager.GetHandlerPath(typeof(InstallerHandler)).ReplaceFirst("*", WebResources.GetString("FileDownload.BaseName")).Replace("*", "exe");


To generate a URL to download the client jnlp:

Code:

var handlerUrl = new Uri(HttpContext.Current.Request.Url, HttpRuntime.AppDomainAppVirtualPath)
    + WebConfigurationManager.GetHandlerPath(typeof(WebStartDirectHandler)).ReplaceFirst("*", WebResources.GetString("FileDownload.BaseName"));


To generate a URL to download the Mac bundle:

Code:

var handlerUrl = new Uri(HttpContext.Current.Request.Url, HttpRuntime.AppDomainAppVirtualPath)
    + WebConfigurationManager.GetHandlerPath(typeof(MacBundleDownloadHandler)).ReplaceFirst("*", WebResources.GetString("FileDownload.BaseName"));


The GetLaunchUrlFromName and GetLaunchUrlFromSessionID methods should be called via HTTP POST with application/json Content-Type header and ScreenConnect user credentials (the direct join link contains an access token parameter generated for the user associated with the provided credentials). The follow code snippet offers an example of how to make the request to GetLaunchUrlFromSessionID using C# and .NET:

Code:

var sessionID = "7e6e6436-8295-4854-9345-63159359efdf";
using (var webClient = new WebClient())
{
    webClient.Headers.Add("Content-Type", "application/json");
    webClient.Headers.Add("Accept", "application/json");
    webClient.Credentials = new NetworkCredential("ScreenConnectUsername", "ScreenConnectPassword");
    
    try
    {
        var launchUrl = System.Text.RegularExpressions.Regex.Unescape( 
                webClient.UploadString(
                    "https://myScreenConnectUrl.com/App_Extensions/4cf8c008-db74-435a-8dee-db2bc073fee5/Service.ashx/GetLaunchUrlFromSessionID",
                    "POST",
                    "[\"" + sessionID + "\"]"
                )
            );

            Console.WriteLine(launchUrl);
    }
    catch (WebException e)
    {
        Console.WriteLine(e.Message);
    }
}

Edited by user Wednesday, November 9, 2016 7:25:34 PM(UTC)  | Reason: additional info

ScreenConnect Team

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.