logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

2 Pages<12
Options
Go to last post Go to first unread
rgreen83  
#51 Posted : Thursday, June 25, 2015 1:52:29 AM(UTC)
rgreen83


Rank: Advanced Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 2/16/2015(UTC)
Posts: 68
United States
Location: Missouri

Thanks: 6 times
Was thanked: 3 time(s) in 3 post(s)
Alexander could you see if this needs updated for 5.3? It's not working for me and just wanted to check its right before digging in. I think the references to Elsinore need removed?
Alexander  
#52 Posted : Thursday, June 25, 2015 2:20:30 PM(UTC)
Alexander


Rank: Administration

Medals: Level 3: Shirt off your back! Received 25 Thanks!

Joined: 7/23/2013(UTC)
Posts: 714
Man
Location: Raleigh, NC

Was thanked: 66 time(s) in 63 post(s)
Yeah, just removing the "Elsinore." in the usings and the Uri should make it work.
ScreenConnect Team
rgreen83  
#53 Posted : Thursday, June 25, 2015 2:42:46 PM(UTC)
rgreen83


Rank: Advanced Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 2/16/2015(UTC)
Posts: 68
United States
Location: Missouri

Thanks: 6 times
Was thanked: 3 time(s) in 3 post(s)
Ya I was able to get this working with 5.3 last night. Remove Elsinore references and change Bin/ScreenConnect.WindowsClient.application to Bin/ScreenConnect.Client.application was required, at least for me.
rgreen83  
#54 Posted : Thursday, July 2, 2015 1:49:57 PM(UTC)
rgreen83


Rank: Advanced Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 2/16/2015(UTC)
Posts: 68
United States
Location: Missouri

Thanks: 6 times
Was thanked: 3 time(s) in 3 post(s)
How could I change the LaunchHostClient.ashx file so that users who are limited to only joining sessions in certain session groups can connect to those groups? Currently they don't have permissions to the "All Machines" group because I don't want them to be able to see or connect to all machines but the way this handler is setup they can't connect to the ones that they do have permissions to either. I would still need users who do have permission to "All Machines" to be able to connect accordingly.

TIA

Edited by user Thursday, July 2, 2015 1:52:31 PM(UTC)  | Reason: Not specified

Alexander  
#55 Posted : Thursday, July 2, 2015 2:30:06 PM(UTC)
Alexander


Rank: Administration

Medals: Level 3: Shirt off your back! Received 25 Thanks!

Joined: 7/23/2013(UTC)
Posts: 714
Man
Location: Raleigh, NC

Was thanked: 66 time(s) in 63 post(s)
ScreenConnector's Service.ashx can handle that better:

Code:
using System;
using System.Configuration;
using System.Web;
using System.Linq;
using Elsinore.ScreenConnect;

public class Service : WebServiceBase
{
	public object GetLaunchUrl(string sessionName)
	{
		var permissionEntries = Permissions.GetEntriesForUser();
		Permissions.AssertAnyPermission(permissionEntries);

		var sessionFilter = ServerExtensions.GetExpression("Name", "=", sessionName);
		var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true);
		var userDisplayName = FormsAuthenticationModule.GetUserDisplayNameWithFallback(HttpContext.Current.User);
		var variables = ServerExtensions.GetStandardVariables(userDisplayName);
		var handlerUrl = ServerExtensions.GetWebServerUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true) + WebConfigurationManager.GetHandlerPath(typeof(ClickOnceDirectHandler)).ReplaceFirst("*", WebResources.GetString("FileDownload.BaseName"));
		
		return
			(from session in SessionManagerPool.Demux.GetSessions(sessionFilter)
			from groupContainingSession in SessionManagerPool.Demux.GetSessionGroupsContainingSession(session.SessionID, variables)
			where Permissions.HasPermission(new SessionPermissionRequest { Name = PermissionInfo.ViewSessionGroupPermission, SessionType = session.SessionType, SessionGroupName = groupContainingSession }, permissionEntries)
			let sessionPermissions = PermissionInfo.GetSessionPermissions(permissionEntries, session.SessionType, groupContainingSession, session.Host == userDisplayName)
			select new ClientLaunchParameters
			{
				Host = relayUri.Host,
				Port = relayUri.Port,
				EncryptionKey = ServerCryptoManager.Instance.PublicKey,
				SessionType = session.SessionType,
				SessionID = session.SessionID,
				ProcessType = ProcessType.Host,
				SessionTitle = session.Name,
				AccessToken = ServerCryptoManager.Instance.GetAccessToken(session.SessionID, ProcessType.Host, userDisplayName, sessionPermissions, default(DateTime)),
			})
			.FirstOrDefault()
			.SafeNav(clp => handlerUrl + ClientLaunchParameters.ToQueryString(clp));
	}
}
ScreenConnect Team
rgreen83  
#56 Posted : Thursday, July 2, 2015 4:53:42 PM(UTC)
rgreen83


Rank: Advanced Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 2/16/2015(UTC)
Posts: 68
United States
Location: Missouri

Thanks: 6 times
Was thanked: 3 time(s) in 3 post(s)
Indeed it does work perfectly and I already had that extension installed! Thanks again!
rgreen83  
#57 Posted : Friday, July 3, 2015 6:31:26 PM(UTC)
rgreen83


Rank: Advanced Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 2/16/2015(UTC)
Posts: 68
United States
Location: Missouri

Thanks: 6 times
Was thanked: 3 time(s) in 3 post(s)
I take that back, I haven't been able to get this working with the screenconnect service.ashx, I think it may have been caching some stuff is why I thought it was working. I think using the service.ashx would require several changes to how I am currently connecting. I'm just a lowly system/network admin and not a programmer so I don't have the skills to make these changes so I'm just going to post what I know here and maybe someone else will want to do the same thing some day as I realize I may be asking too much for Alexander to spoon feed me.

I could also just call screenconnector.exe directly with the required parameters but it requires a different encryption method, there is a utility here http://forum.screenconne...ws-taskbar.aspx#post6553 for hashing the passwords but as I am generating the commands to launch the session on the fly via powershell that isn't helping for my case as I haven't been able to find any documentation of a powershell way to encrypt with .NET ProtectData.Protect method.

Im also limited to a 500 character limit by a database field, this is what my PS command looks like when using LaunchHostClient.ashx and it works great other than the session group permission issue. I know that the service.ashx expects a different format of data but I haven't been able to figure out what that would be either. For now I will just have to use this and will be happy enough.

Code:
$F=$env:USERPROFILE+'\SCCreds.xml';$E=Test-Path $F;if($E -eq $false){get-credential|EXPORT-CLIXML $F};$c=IMPORT-CLIXML $F;$a=$c.GetNetworkCredential().password;$r=invoke-webrequest -uri http://sc.fqdn.com/LHC.ashx?ID=$GUID -Headers @{"Authorization"='Basic '+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($c.username+':'+$a))};Invoke-Expression 'rundll32 dfshim.dll,ShOpenVerbApplication $r.content'


I got the powershell here http://www.labtechgeek.c...topic.php?f=3&t=1078

Also from the above thread the LaunchHostClient.ashx that I am using has been modified to allow opening sessions with the sessionID instead of by name as the name is not always unique for many in the msp business. I think I may be able to get the service.ashx working for my needs if I knew how to smash it and the launchhostclient.ashx together :)

Code:
<%@ WebHandler Language="C#" Class="LaunchHostClient" %>
  
using System;
using System.Web;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using ScreenConnect;
 
public class LaunchHostClient : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        Permissions.AssertPermission(PermissionInfo.JoinSessionPermission, false);
         
        var sessionID = context.Request.QueryString["ID"];
        var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true);
 
        using (var sessionManager = ServiceChannelPool<ISessionManagerChannel>.Instance.Borrow())
        {
            var sessionSummary = sessionManager.GetSessions("All Machines", new Dictionary<string, string>(), null).First(ss => ss.SessionID.ToString() == sessionID);
 
            var clp = new ClientLaunchParameters();
            clp.Host = relayUri.Host;
            clp.Port = relayUri.Port;
            clp.SessionID = sessionSummary.SessionID;
            clp.ProcessType = ProcessType.Host;
            clp.EncryptionKey = ServerCryptoManager.Instance.PublicKey;
            clp.AccessToken = ServerCryptoManager.Instance.GetAccessToken(clp.SessionID, clp.ProcessType, context.User.Identity.Name, SessionPermissions.HostWithoutRemoteConsent | SessionPermissions.RunSharedTool | SessionPermissions.TransferFiles | SessionPermissions.ManageSharedToolbox, DateTime.MinValue);
 
            clp.SessionTitle = sessionSummary.Name;
 
            var url = new Uri(context.Request.Url, "Bin/ScreenConnect.Client.application" + ClientLaunchParameters.ToQueryString(clp));
            context.Response.Write(url.AbsoluteUri);
        }
    }
 
    public bool IsReusable { get { return false; } }
}

Edited by user Friday, July 3, 2015 9:31:58 PM(UTC)  | Reason: clarify

Alexander  
#58 Posted : Monday, July 6, 2015 2:41:38 PM(UTC)
Alexander


Rank: Administration

Medals: Level 3: Shirt off your back! Received 25 Thanks!

Joined: 7/23/2013(UTC)
Posts: 714
Man
Location: Raleigh, NC

Was thanked: 66 time(s) in 63 post(s)
In case you haven't seen it, there's a modified launch.cmd for ScreenConnector's Service.ashx at the bottom of the previous page of this thread; it uses a different url format, and returns quotes around the output that have to be removed.

Smashing the two files together shouldn't be too difficult either, though; I haven't tested it, but I believe this would work:
Code:
<%@ WebHandler Language="C#" Class="LaunchHostClient" %>

using System;
using System.Web;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using ScreenConnect;

public class LaunchHostClient : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
        var permissionEntries = Permissions.GetEntriesForUser();
        Permissions.AssertAnyPermission(permissionEntries);
 
        var sessionFilter = ServerExtensions.GetExpression("SessionID", "=", context.Request.QueryString["ID"]);
        var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true);
        var userDisplayName = FormsAuthenticationModule.GetUserDisplayNameWithFallback(HttpContext.Current.User);
        var variables = ServerExtensions.GetStandardVariables(userDisplayName);
        var handlerUrl = ServerExtensions.GetWebServerUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true) + WebConfigurationManager.GetHandlerPath(typeof(ClickOnceDirectHandler)).ReplaceFirst("*", WebResources.GetString("FileDownload.BaseName"));
         
        (from session in SessionManagerPool.Demux.GetSessions(sessionFilter)
            from groupContainingSession in SessionManagerPool.Demux.GetSessionGroupsContainingSession(session.SessionID, variables)
            where Permissions.HasPermission(new SessionPermissionRequest { Name = PermissionInfo.ViewSessionGroupPermission, SessionType = session.SessionType, SessionGroupName = groupContainingSession }, permissionEntries)
            let sessionPermissions = PermissionInfo.GetSessionPermissions(permissionEntries, session.SessionType, groupContainingSession, session.Host == userDisplayName)
            select new ClientLaunchParameters
            {
                Host = relayUri.Host,
                Port = relayUri.Port,
                EncryptionKey = ServerCryptoManager.Instance.PublicKey,
                SessionType = session.SessionType,
                SessionID = session.SessionID,
                ProcessType = ProcessType.Host,
                SessionTitle = session.Name,
                AccessToken = ServerCryptoManager.Instance.GetAccessToken(session.SessionID, ProcessType.Host, userDisplayName, sessionPermissions, default(DateTime)),
            })
            .FirstOrDefault()
            .SafeDo(clp => context.Response.Write(new Uri(handlerUrl + ClientLaunchParameters.ToQueryString(clp))));
}

public bool IsReusable { get { return false; } }
}
ScreenConnect Team
rgreen83  
#59 Posted : Wednesday, July 8, 2015 8:46:20 PM(UTC)
rgreen83


Rank: Advanced Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 2/16/2015(UTC)
Posts: 68
United States
Location: Missouri

Thanks: 6 times
Was thanked: 3 time(s) in 3 post(s)
Thank you so much for continuing to help me with this. I did see the launch.cmd, I was able to get that to work after getting a different curl.exe that included ssl support, but due to the limitations in the program im using I don't know how to incorporate using curl without passing credentials in plaintext.

The new LaunchHostClient.ashx file you posted is exactly what I need and it is very near working! I have tested it a lot to try eliminate user error, but for some reason this file is returning the &k= key back in a different format than the original LHC file did and this gives an error of "Bad Length" when i launch the downloaded client.application, everything else looks right though. The &k= key returned is a bit shorter and has some characters in it like + and / that are not in the key returned by the original. At first glance it looked like the key is just not in a url encoded format but encoding it causes the client.application to crash on launch.
Alexander  
#60 Posted : Wednesday, July 8, 2015 10:11:54 PM(UTC)
Alexander


Rank: Administration

Medals: Level 3: Shirt off your back! Received 25 Thanks!

Joined: 7/23/2013(UTC)
Posts: 714
Man
Location: Raleigh, NC

Was thanked: 66 time(s) in 63 post(s)
Hmm, looks like it's that .AbsoluteUri that makes it be encoded properly; putting that after new Uri(handlerUrl + ClientLaunchParameters.ToQueryString(clp)) should make it work.
ScreenConnect Team
rgreen83  
#61 Posted : Thursday, July 9, 2015 2:59:57 PM(UTC)
rgreen83


Rank: Advanced Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 2/16/2015(UTC)
Posts: 68
United States
Location: Missouri

Thanks: 6 times
Was thanked: 3 time(s) in 3 post(s)
That worked perfectly! I've tested the heck out of it and its working great. Thanks so much!
CTaylor  
#62 Posted : Wednesday, December 23, 2015 1:58:19 AM(UTC)
CTaylor


Rank: Newbie

Joined: 11/26/2015(UTC)
Posts: 1
Location: USA

I have been using this and it is working great. I have an issue with the consent permissions though. When connecting to machines that require consent this seems to bypass that permission and I can connect without consent when I should not be able to.
Alexander  
#63 Posted : Wednesday, December 23, 2015 3:33:26 PM(UTC)
Alexander


Rank: Administration

Medals: Level 3: Shirt off your back! Received 25 Thanks!

Joined: 7/23/2013(UTC)
Posts: 714
Man
Location: Raleigh, NC

Was thanked: 66 time(s) in 63 post(s)
Hmm, that might be the same issue mentioned here; they were needing consent when they shouldn't have, while you don't need it when you should, but I suspect the underlying cause is the same.
ScreenConnect Team
rgreen83  
#64 Posted : Monday, April 11, 2016 12:10:44 AM(UTC)
rgreen83


Rank: Advanced Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 2/16/2015(UTC)
Posts: 68
United States
Location: Missouri

Thanks: 6 times
Was thanked: 3 time(s) in 3 post(s)
*Edit* One of my in house guys, lemtargatwing, was able to figure out that "var userDisplayName" needs to be "string userDisplayName" in 5.6.

Looks like LaunchHostClient.ashx might be broken with 5.6?
Current LHC.ashx
Code:
<%@ WebHandler Language="C#" Class="LaunchHostClient" %>
 
using System;
using System.Web;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using ScreenConnect;
 
public class LaunchHostClient : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
        var permissionEntries = Permissions.GetEntriesForUser();
        Permissions.AssertAnyPermission(permissionEntries);
  
        var sessionFilter = ServerExtensions.GetExpression("SessionID", "=", context.Request.QueryString["ID"]);
        var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true);
        var userDisplayName = FormsAuthenticationModule.GetUserDisplayNameWithFallback(HttpContext.Current.User);
        var variables = ServerExtensions.GetStandardVariables(userDisplayName);
        var handlerUrl = ServerExtensions.GetWebServerUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true) + WebConfigurationManager.GetHandlerPath(typeof(ClickOnceDirectHandler)).ReplaceFirst("*", WebResources.GetString("FileDownload.BaseName"));
          
        (from session in SessionManagerPool.Demux.GetSessions(sessionFilter)
            from groupContainingSession in SessionManagerPool.Demux.GetSessionGroupsContainingSession(session.SessionID, variables)
            where Permissions.HasPermission(new SessionPermissionRequest { Name = PermissionInfo.ViewSessionGroupPermission, SessionType = session.SessionType, SessionGroupName = groupContainingSession }, permissionEntries)
            let sessionPermissions = PermissionInfo.GetSessionPermissions(permissionEntries, session.SessionType, groupContainingSession, session.Host == userDisplayName)
            select new ClientLaunchParameters
            {
                Host = relayUri.Host,
                Port = relayUri.Port,
                EncryptionKey = ServerCryptoManager.Instance.PublicKey,
                SessionType = session.SessionType,
                SessionID = session.SessionID,
                ProcessType = ProcessType.Host,
                SessionTitle = session.Name,
                AccessToken = ServerCryptoManager.Instance.GetAccessToken(session.SessionID, ProcessType.Host, userDisplayName, sessionPermissions, default(DateTime)),
            })
            .FirstOrDefault()
            .SafeDo(clp => context.Response.Write(new Uri(handlerUrl + ClientLaunchParameters.ToQueryString(clp)).AbsoluteUri));
}
 
public bool IsReusable { get { return false; } }
}

connection code
Code:
$F=$env:USERPROFILE+'\SCCreds.xml'
$E=Test-Path $F;if($E -eq $false){get-credential|EXPORT-CLIXML $F}
$c=IMPORT-CLIXML $F
$a=$c.GetNetworkCredential().password
$r=invoke-webrequest -uri https://sc.fqdn.com/LHC.ashx?ID=0f5d432c-66e0-4e22-87f8-ebfdf8503018 -Headers @{"Authorization"='Basic '+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($c.username+':'+$a))};Invoke-Expression 'rundll32 dfshim.dll,ShOpenVerbApplication $r.content'

error text

Edited by user Monday, April 11, 2016 2:36:01 PM(UTC)  | Reason: Not specified

Alexander  
#65 Posted : Monday, April 11, 2016 2:44:24 PM(UTC)
Alexander


Rank: Administration

Medals: Level 3: Shirt off your back! Received 25 Thanks!

Joined: 7/23/2013(UTC)
Posts: 714
Man
Location: Raleigh, NC

Was thanked: 66 time(s) in 63 post(s)
Changing ServerExtensions.GetStandardVariables(userDisplayName) to ServerExtensions.GetStandardVariables(HttpContext.Current.User) should fix that.
ScreenConnect Team
thanks 1 user thanked Alexander for this useful post.
rgreen83 on 4/12/2016(UTC)
BrantB8771  
#66 Posted : Thursday, August 3, 2017 4:51:29 AM(UTC)
BrantB8771


Rank: Guest

Joined: 6/1/2016(UTC)
Posts: 1
United States

Thanks: 3 times
I've recently run into the same scenario - a need to frequently access a computer installed as Unattended Support, AND "My Unattended Computers" (MUCs). To appease many, we created a 30-second countdown window wherein the supported user must "consent to control". It's a nice option, but we've tweaked our config so that we can immediately access the handful of computers we've installed as MUCs.

It would've been nice if the ScreenConnector would see that, based on our credentials, that it's okay to let us straight through to those odd MUCs.

Any chance this is now a feature implemented in the 3 years since the above, last post?
jaywonnng  
#67 Posted : Wednesday, August 9, 2017 9:51:24 PM(UTC)
jaywonnng


Rank: Guest

Joined: 8/9/2017(UTC)
Posts: 1
Canada
Location: Vancouver

Hi all,

Also running into this situation where a direct connection link/script is needed. Newly screen-connect member so first time mucking around the software.

I've followed through this post and tried BOTH LaunchHostClient.ashx and Service.ashx

Currently I am getting a "Value does not fall within the expected range"

Any help is greatly appreciated! thanks guys!

Stack Trace :
Code:

[ArgumentException: Value does not fall within the expected range.]
   ScreenConnect.Extensions.AssertArgumentNonNull(T obj) +53
   ScreenConnect.ServerExtensions.GetExpression(String columnExpression, String operatorString, Object value) +53
   LaunchHostClient.ProcessRequest(HttpContext context) +145
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +798
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +91


LaunchHostClient.ashx :

When I change "ID" to "Tag" I get prompted to enter my credentials which validate but I get nothing a completely blank HTML page... I feel like this is close but have hit a road block...
Code:

<%@ WebHandler Language="C#" Class="LaunchHostClient" %>
 
using System;
using System.Web;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using ScreenConnect;
 
public class LaunchHostClient : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
        var permissionEntries = Permissions.GetEntriesForUser();
        Permissions.AssertAnyPermission(permissionEntries);
  
        var sessionFilter = ServerExtensions.GetExpression("SessionID", "=", context.Request.QueryString["ID"]);
        var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true);
        var userDisplayName = FormsAuthenticationModule.GetUserDisplayNameWithFallback(HttpContext.Current.User);
        var variables = ServerExtensions.GetStandardVariables(HttpContext.Current.User);
        var handlerUrl = ServerExtensions.GetWebServerUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true) + WebConfigurationManager.GetHandlerPath(typeof(ClickOnceDirectHandler)).ReplaceFirst("*", WebResources.GetString("FileDownload.BaseName"));
          
        (from session in SessionManagerPool.Demux.GetSessions(sessionFilter)
            from groupContainingSession in SessionManagerPool.Demux.GetSessionGroupsContainingSession(session.SessionID, variables)
            where Permissions.HasPermission(new SessionPermissionRequest { Name = PermissionInfo.ViewSessionGroupPermission, SessionType = session.SessionType, SessionGroupName = groupContainingSession }, permissionEntries)
            let sessionPermissions = PermissionInfo.GetSessionPermissions(permissionEntries, session.SessionType, groupContainingSession, session.Host == userDisplayName)
            select new ClientLaunchParameters
            {
                Host = relayUri.Host,
                Port = relayUri.Port,
                EncryptionKey = ServerCryptoManager.Instance.PublicKey,
                SessionType = session.SessionType,
                SessionID = session.SessionID,
                ProcessType = ProcessType.Host,
                SessionTitle = session.Name,
                AccessToken = ServerCryptoManager.Instance.GetAccessToken(session.SessionID, ProcessType.Host, userDisplayName, sessionPermissions, default(DateTime)),
            })
            .FirstOrDefault()
            .SafeDo(clp => context.Response.Write(new Uri(handlerUrl + ClientLaunchParameters.ToQueryString(clp)).AbsoluteUri));
}
 
public bool IsReusable { get { return false; } }
}


Service.ashx
Code:

<%@ WebHandler Language="C#" Class="LaunchHostClient" %>

using System;
using System.Web;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using ScreenConnect;

public class LaunchHostClient : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
        var permissionEntries = Permissions.GetEntriesForUser();
        Permissions.AssertAnyPermission(permissionEntries);
 
        var sessionFilter = ServerExtensions.GetExpression("SessionID", "=", context.Request.QueryString["ID"]);
        var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true);
        var userDisplayName = FormsAuthenticationModule.GetUserDisplayNameWithFallback(HttpContext.Current.User);
        var variables = ServerExtensions.GetStandardVariables(HttpContext.Current.User);
        var handlerUrl = ServerExtensions.GetWebServerUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true) + WebConfigurationManager.GetHandlerPath(typeof(ClickOnceDirectHandler)).ReplaceFirst("*", WebResources.GetString("FileDownload.BaseName"));
         
        (from session in SessionManagerPool.Demux.GetSessions(sessionFilter)
            from groupContainingSession in SessionManagerPool.Demux.GetSessionGroupsContainingSession(session.SessionID, variables)
            where Permissions.HasPermission(new SessionPermissionRequest { Name = PermissionInfo.ViewSessionGroupPermission, SessionType = session.SessionType, SessionGroupName = groupContainingSession }, permissionEntries)
            let sessionPermissions = PermissionInfo.GetSessionPermissions(permissionEntries, session.SessionType, groupContainingSession, session.Host == userDisplayName)
            select new ClientLaunchParameters
            {
                Host = relayUri.Host,
                Port = relayUri.Port,
                EncryptionKey = ServerCryptoManager.Instance.PublicKey,
                SessionType = session.SessionType,
                SessionID = session.SessionID,
                ProcessType = ProcessType.Host,
                SessionTitle = session.Name,
                AccessToken = ServerCryptoManager.Instance.GetAccessToken(session.SessionID, ProcessType.Host, userDisplayName, sessionPermissions, default(DateTime)),
            })
            .FirstOrDefault()
            .SafeDo(clp => context.Response.Write(new Uri(handlerUrl + ClientLaunchParameters.ToQueryString(clp)).AbsoluteUri));
}

public bool IsReusable { get { return false; } }
}


and my launch.cmd

Code:

for /f %%A IN ('curl.exe -u %4:%5 http://%1:%2/App_Extensions/b5ca823a-7c62-4920-81d7-61aaa1e9eaa2/Service.ashx/GetLaunchUrl/%3') DO SET URL=%%A
SET UNQUOTED_URL=%URL:"=%
rundll32 dfshim.dll,ShOpenVerbApplication %UNQUOTED_URL:\u0026=^&%


AND

Code:

for /f %%A IN ('curl.exe -u %4:%5 http://%1:%2/LaunchHostClient.ashx?Tag^=%3') DO SET URL=%%A
rundll32 dfshim.dll,ShOpenVerbApplication %URL:&=^&%

Edited by user Wednesday, August 9, 2017 11:00:44 PM(UTC)  | Reason: Not specified

rgreen83  
#68 Posted : Thursday, August 10, 2017 7:00:12 AM(UTC)
rgreen83


Rank: Advanced Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 2/16/2015(UTC)
Posts: 68
United States
Location: Missouri

Thanks: 6 times
Was thanked: 3 time(s) in 3 post(s)
@jaywonnng
It looks like your Service.ashx and LaunchHostClient.ashx are the same, and that they match the combined functions of both smashed together version of both that Alexander helped me out with further up this page. I'm still using that same file today with 6.3 and it is working, I use powershell in my function but I was able to get it working with curl as well.

LaunchHostClient.ashx
Code:
<%@ WebHandler Language="C#" Class="LaunchHostClient" %>
 
using System;
using System.Web;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using ScreenConnect;
 
public class LaunchHostClient : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
        var permissionEntries = Permissions.GetEntriesForUser();
        Permissions.AssertAnyPermission(permissionEntries);
  
        var sessionFilter = ServerExtensions.GetExpression("SessionID", "=", context.Request.QueryString["ID"]);
        var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true);
        var userDisplayName = FormsAuthenticationModule.GetUserDisplayNameWithFallback(HttpContext.Current.User);
        var variables = ServerExtensions.GetStandardVariables(HttpContext.Current.User);
        var handlerUrl = ServerExtensions.GetWebServerUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true) + WebConfigurationManager.GetHandlerPath(typeof(ClickOnceDirectHandler)).ReplaceFirst("*", WebResources.GetString("FileDownload.BaseName"));
          
        (from session in SessionManagerPool.Demux.GetSessions(sessionFilter)
            from groupContainingSession in SessionManagerPool.Demux.GetSessionGroupsContainingSession(session.SessionID, variables)
            where Permissions.HasPermission(new SessionPermissionRequest { Name = PermissionInfo.ViewSessionGroupPermission, SessionType = session.SessionType, SessionGroupName = groupContainingSession }, permissionEntries)
            let sessionPermissions = PermissionInfo.GetSessionPermissions(permissionEntries, session.SessionType, groupContainingSession, session.Host == userDisplayName)
            select new ClientLaunchParameters
            {
                Host = relayUri.Host,
                Port = relayUri.Port,
                EncryptionKey = ServerCryptoManager.Instance.PublicKey,
                SessionType = session.SessionType,
                SessionID = session.SessionID,
                ProcessType = ProcessType.Host,
                SessionTitle = session.Name,
                AccessToken = ServerCryptoManager.Instance.GetAccessToken(session.SessionID, ProcessType.Host, userDisplayName, sessionPermissions, default(DateTime)),
            })
            .FirstOrDefault()
            .SafeDo(clp => context.Response.Write(new Uri(handlerUrl + ClientLaunchParameters.ToQueryString(clp)).AbsoluteUri));
}
 
public bool IsReusable { get { return false; } }
}


launch.cmd

Code:
for /f %%A IN ('curl.exe -u %4:%5 https://%1:%2/LaunchHostClient.ashx?ID^=%3') DO SET URL=%%A
rundll32 dfshim.dll,ShOpenVerbApplication %URL:&=^&%


cmd

Code:
launch.cmd sc.fqdn.com port sessionid username password


Some things I ran into doing this in curl since it has been a long time since I touched this and one of them may be hanging you up as well:
if you enforce https, make sure you use https in your launch.cmd
confirm your port in the launch.cmd
authentication will fail if the user has 2 factor authentication enforced

If all else fails I would suggest using the powershell method i've posted previously as it helps to be able to dump variables out individually when troubleshooting
Users browsing this topic
Similar Topics
Command line to join an unattended session as Host in 4.0 (Advanced Customization)
by eastrand 10/1/2013 11:52:43 PM(UTC)
Command line to join an unattended session as Host (Advanced Customization)
by JeffBower 5/18/2011 1:34:39 PM(UTC)
2 Pages<12
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.