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

Notification

Icon
Error

2 Pages12>
Options
Go to last post Go to first unread
JeffBower  
#1 Posted : Wednesday, May 18, 2011 1:34:39 PM(UTC)
JeffBower


Rank: Member

Joined: 5/14/2010(UTC)
Posts: 18
Man
Location: Chicago

Hi-

I need a command line to join (as Host) an established unattended session. What I am trying to do is integrate with Dell Kase, which allows me to add a command line to an action/button. I would have approximately 150 machines/unattended sessions, which would identify via IP. Is this possible and, if so, how?

Thanks!
Jeff
Jake  
#2 Posted : Thursday, May 19, 2011 9:28:15 PM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
I'm not familiar with Dell Kace. It sounds like a rich client app if it's running a command line. Still, it would probably be best to launch internet explorer with a URL of a page on your ScreenConnect installation. Have you setup the unattended sessions yet? Can you tag them with something useful to connect with, or will you need to go beyond the tag to find the sessions by IP?
ScreenConnect Team
Jake  
#3 Posted : Thursday, May 26, 2011 4:01:13 PM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
Here is a page that you can put in your ScreenConnect directory that will redirect to launch the host:

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

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

public class LaunchHostClient : IHttpHandler
{
	public void ProcessRequest(HttpContext context)
	{
		var sessionTag = context.Request.QueryString["Tag"];
		var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true);

		using (var sessionManager = ServerExtensions.SessionManagerChannelFactory.CreateChannel())
		{
			var sessionSummary = sessionManager.GetSessionSummaries("All Machines", new Dictionary<string, string>(), null).First(ss => string.Equals(ss.Tag, sessionTag, StringComparison.InvariantCultureIgnoreCase));

			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);
			clp.ApplicationTitle = Resources.Default.Client_ApplicationTitle;
			clp.SessionTitle = sessionSummary.Tag;

			var url = "Bin/Elsinore.ScreenConnect.HostClient.application" + ClientLaunchParameters.ToQueryString(clp);
			context.Response.AppendHeader("Refresh", "0; URL=" + url);		
			
			// does the right thing with the browser, but reports the wrong query string	
			//context.Response.Redirect(url);
		}
	}

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


It takes a parameter "Tag" and will connect to the session with that tag.

From the command line:

Code:
"iexplore.exe" "http://localhost:8040/LaunchHostClient.ashx?Tag=DURHAM"


It works, but leaves up the IE window.





This method gets never uses IE and should work, but doesn't like any redirects:

Code:
rundll32 dfshim.dll,ShOpenVerbApplication "http://localhost:8040/LaunchHostClient.ashx?Tag=DURHAM"


Also uncommenting the redirect line up in the code should work and use IE, but then the wrong activation URI is reported to the clickonce app. So we have to do a client redirect (appendheader) rather than a server redirect (response.redirect). The problem here is that it leaves up the IE window.

Really the optimal solution would be for you to have a script file that did a wget of the LaunchHostClient.ashx, then ran the results with rundll32.
File Attachment(s):
LaunchHostClient.ashx (2kb) downloaded 172 time(s).
ScreenConnect Team
Jake  
#4 Posted : Thursday, May 26, 2011 6:01:50 PM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
Oh, and along with the rambling from above. Let me present the disclaimer that the above code only works with 2.2.1600 or greater ... which isn't even available yet. Hoping to get it out soon through.
ScreenConnect Team
Jake  
#5 Posted : Thursday, June 16, 2011 10:32:35 AM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
Try this, to use with wget/curl:

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

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

public class LaunchHostClient : IHttpHandler
{
	public void ProcessRequest(HttpContext context)
	{
		var sessionTag = context.Request.QueryString["Tag"];
		var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true);

		using (var sessionManager = ServerExtensions.SessionManagerChannelFactory.CreateChannel())
		{
			var sessionSummary = sessionManager.GetSessionSummaries("All Machines", new Dictionary<string, string>(), null).First(ss => string.Equals(ss.Tag, sessionTag, StringComparison.InvariantCultureIgnoreCase));

			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);
			clp.ApplicationTitle = Resources.Default.Client_ApplicationTitle;
			clp.SessionTitle = sessionSummary.Tag;

			var url = new Uri(context.Request.Url, "Bin/Elsinore.ScreenConnect.HostClient.application" + ClientLaunchParameters.ToQueryString(clp));
			context.Response.Write(url);

		}
	}

	public bool IsReusable { get { return false; } }
}
File Attachment(s):
LaunchHostClient.ashx (2kb) downloaded 105 time(s).
ScreenConnect Team
Jake  
#6 Posted : Thursday, June 16, 2011 10:47:06 AM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
This needs to change:

Code:
context.Response.Write(url);


To this:

Code:
context.Response.Write(url.OriginalString);
ScreenConnect Team
Jake  
#7 Posted : Thursday, June 16, 2011 10:50:20 AM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
Here is a launch.cmd file that will launch with rundll32 rather than involving IE:

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


To launch from command line:

Code:
launch.cmd support.myserver.com 8040 MYPCNAME


And you'll need curl.exe in the directory. I've attached my version of curl, but I can't vouch for it's authenticity.

Edited by user Thursday, June 16, 2011 11:25:53 AM(UTC)  | Reason: Not specified

File Attachment(s):
curl.exe (391kb) downloaded 152 time(s).
launch.cmd (1kb) downloaded 126 time(s).
ScreenConnect Team
bradcccs  
#8 Posted : Saturday, October 8, 2011 9:09:58 PM(UTC)
bradcccs


Rank: Newbie

Joined: 10/8/2011(UTC)
Posts: 6

Hey Jake,

Thanks for your efforts on the LaunchHostClient concept - has been a great addition to our arsenal.

We are currently calling via IE and thus end up with a lot of "dead IE windows".
(edit: Should mention that calling via IE is indeed working but just leaves the windows open as mentioned)

Having no luck converting over to CURL.

Version = 2.3.1918.4269


Variation on the context.Response that we are using:
Code:

context.Response.AppendHeader("Refresh", "0; URL=" + url.AbsoluteUri);


The CURL progress window shows no progress (0's) and thus the rundll request does not receive relevant info and is generated as
Code:

rundll32 dfshim.dll,ShOpenVerbApplication &=^&



The resultant log reports that the "URI is empty"

Code:

ERROR DETAILS
	Following errors were detected during this operation.
	* [9/10/2011 11:59:00 AM] System.UriFormatException
		- Invalid URI: The URI is empty.
		- Source: System
		- Stack trace:
			at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
			at System.Uri..ctor(String uriString)
			at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)



Am I upsetting the apple cart using the "AppendHeader" response?

I am by no means an expert on this subject so any assistance is appreciated. Remains as the last piece to the puzzle before we switch 100% to the SC solution for our remote support needs.

Cheers

Brad

Edited by user Saturday, October 8, 2011 9:13:17 PM(UTC)  | Reason: Not specified

Jake  
#9 Posted : Saturday, October 15, 2011 5:55:34 PM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
You'll want to Response.Write the URL from your handler rather than send it as a header. If you response.write it, curl will get the output and you should be set.
ScreenConnect Team
nkayoumi  
#10 Posted : Wednesday, December 14, 2011 11:48:42 AM(UTC)
nkayoumi


Rank: Member

Joined: 12/1/2011(UTC)
Posts: 20

I created the ashx and it launches the host client successfully. But it works only if I'm logged-on to the site. If I'm not logged-on, it launches a user logon window. I read someplace on the forums that the host client can be launched without authentication but one has to pass a token to it. Where do I specify the token in the code above?

Thanks
nkayoumi  
#11 Posted : Wednesday, December 14, 2011 1:07:20 PM(UTC)
nkayoumi


Rank: Member

Joined: 12/1/2011(UTC)
Posts: 20

OK, I see in the LaunchHostClient.ashx that we specify the access token:

Code:
clp.AccessToken = ServerCryptoManager.Instance.GetAccessToken(clp.SessionID, clp.ProcessType, "System");


But I'm still getting the "A user name and password is being requested.." logon window. if I'm not logged on to the web site.

How do I by-pass the authentication completely?
Jake  
#12 Posted : Wednesday, December 14, 2011 5:36:11 PM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
What does your handler file look like?

If there is any line about asserting a permission or anything, remove it.
ScreenConnect Team
nkayoumi  
#13 Posted : Thursday, December 15, 2011 4:14:44 PM(UTC)
nkayoumi


Rank: Member

Joined: 12/1/2011(UTC)
Posts: 20

Thanks. Removing the assert permission fixed the problem! Now when I call the handler from firefox, it launches the host client without a problem. But I get a blank page on IE and host client doesn't get launched.

Launching it from curl give me this error:

Quote:
* Activation of http://remote.test.com/LaunchHostClient.ashx resulted in exception. Following failure messages were detected:
+ Exception reading manifest from http://remote.test.com/LaunchHostClient.ashx: the manifest may not be valid or the file could not be opened.
+ Root element is missing.


Here is my handler code:

Code:

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

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

public class LaunchHostClient : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        var sessionTag = context.Request.QueryString["Tag"];
        var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true);

        using (var sessionManager = Elsinore.ScreenConnect.ServiceChannelPool<Elsinore.ScreenConnect.ISessionManagerChannel>.Instance.Borrow())
        {
            var sessionSummary = sessionManager.GetSessionSummaries("All Machines", new Dictionary<string, string>(), null).First(ss => string.Equals(ss.Tag, sessionTag, StringComparison.InvariantCultureIgnoreCase));

            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, "Administrator");
            clp.ApplicationTitle = Resources.Default.Client_ApplicationTitle;
            clp.SessionTitle = sessionSummary.Tag;

            var url = new Uri(context.Request.Url, "Bin/Elsinore.ScreenConnect.HostClient.application" + ClientLaunchParameters.ToQueryString(clp));            
            //context.Response.Write(url);
            //context.Response.AppendHeader("Refresh", "0; URL=" + url.AbsoluteUri);
            context.Response.Write(url.OriginalString);
            //context.Response.Write(url.AbsoluteUri);

        }
    }

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


I've tried all the different combination of "Response.Write" as shown commented out in the code snippet and had no luck.
nkayoumi  
#14 Posted : Monday, December 19, 2011 3:16:27 PM(UTC)
nkayoumi


Rank: Member

Joined: 12/1/2011(UTC)
Posts: 20

Is this a bug in the software? Anyone?
Jake  
#15 Posted : Monday, December 19, 2011 4:31:11 PM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
How are you using CURL? You need to use CURL to get the URL, then call rundll32 to run the result:

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

ScreenConnect Team
nkayoumi  
#16 Posted : Tuesday, December 20, 2011 5:37:03 PM(UTC)
nkayoumi


Rank: Member

Joined: 12/1/2011(UTC)
Posts: 20

I'm using it exactly like the example above, both the handler and launch.cmd. It's just not working. I have windows 7 64bit. I don't know if that makes a difference.

richy240  
#17 Posted : Wednesday, May 9, 2012 3:39:17 PM(UTC)
richy240


Rank: Newbie

Joined: 5/7/2012(UTC)
Posts: 5
Location: Houston, TX

This isn't working for me, although I think it would be a great start to Kace integration. The error I get is Compiler Error Message: CS0117: 'Elsinore.ScreenConnect.ServerExtensions' does not contain a definition for 'SessionManagerChannelFactory'. I have not yet attempted the curl method... One of the reasons I like the "direct" method of using a URL is that it will work in browsers that aren't IE since it's just opening a URL and not actually launching an application.

I should mention that I am not a developer, so a lot of this is Greek to me. Thank you for any help you can provide.

Edited by user Wednesday, May 9, 2012 3:41:01 PM(UTC)  | Reason: Not specified

Jake  
#18 Posted : Tuesday, June 5, 2012 4:55:15 PM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
The latest code above uses this line instead of the ServerExtensions.SessionManagerChannelFactory ... our API changed:

Code:
        using (var sessionManager = Elsinore.ScreenConnect.ServiceChannelPool<Elsinore.ScreenConnect.ISessionManagerChannel>.Instance.Borrow())
ScreenConnect Team
bradcccs  
#19 Posted : Friday, February 22, 2013 7:17:32 AM(UTC)
bradcccs


Rank: Newbie

Joined: 10/8/2011(UTC)
Posts: 6

Apologies for dredging this one up again...


Having trouble with LaunchHostClient.ashx since upgrading.

Version: 3.1.4099

LaunchHostClient.ashx
Code:

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

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

public class LaunchHostClient : IHttpHandler
{
	public void ProcessRequest(HttpContext context)
	{
		var sessionTag = context.Request.QueryString["Tag"];
		var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true);

		using (var sessionManager = ServiceChannelPool<ISessionManagerChannel>.Instance.Borrow())
		{
			var sessionSummary = sessionManager.GetSessionSummaries("All Machines", new Dictionary<string, string>(), null).First(ss => string.Equals(ss.Tag, sessionTag, StringComparison.InvariantCultureIgnoreCase));

			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);
			
			clp.SessionTitle = sessionTag;

			var url = new Uri(context.Request.Url, "Bin/Elsinore.ScreenConnect.WindowsClient.application" + ClientLaunchParameters.ToQueryString(clp));
			context.Response.Write(url.AbsoluteUri);

		}
	}

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



Compiler Error:
CS1061: 'Elsinore.ScreenConnect.SessionSummary' does not contain a definition for 'Tag' and no extension method 'Tag' accepting a first argument of type 'Elsinore.ScreenConnect.SessionSummary' could be found


Line causing grief:
Code:

var sessionSummary = sessionManager.GetSessionSummaries("All Machines", new Dictionary<string, string>(), null).First(ss => string.Equals(ss.Tag, sessionTag, StringComparison.InvariantCultureIgnoreCase));



Can you confirm ss.tag as being correct in above?

If I set comparison to static values (essentially 1=1), then it successfully connects to the first session in the "All Machines" group. Thus I think if I can get the ss.tag | sessionTag correct I should (hopefully) be back on track.

Any input would be greatly appreciated.

I am in no way an expert in this field, so please feel free to alter/scrap any of the code above.

Cheers

Brad











bradcccs  
#20 Posted : Friday, February 22, 2013 7:34:38 AM(UTC)
bradcccs


Rank: Newbie

Joined: 10/8/2011(UTC)
Posts: 6

Looks like ss.Name has done the trick.

Session now connects as expected, however the connection status shows:

Waiting for consent...
This session requires consent before you can take.....



URL that is output from LaunchHostClient.ashx:

http://servername/Bin/Elsinore.ScreenConnect.WindowsClient.application?e=Support&y=Host&h=servername&p=8041&s=95dd2edd-2add-58dd-97dd-dcdd57gg58gg&k={BigLongRandomString}&n={AShorterRandomString}&t=TargetPC


I have confirmed that user has "HostSessionWithoutConsent" permission set.
Can access same Host from ScreenConnect session list (webpage) without issue
Have tried multiple hosts - all report "Waiting for consent"


Thoughts?

Edited by user Friday, February 22, 2013 7:56:54 AM(UTC)  | Reason: Not specified

Jake  
#21 Posted : Friday, February 22, 2013 7:35:54 AM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
Yeah, that'll do it.
ScreenConnect Team
bradcccs  
#22 Posted : Friday, February 22, 2013 7:59:09 AM(UTC)
bradcccs


Rank: Newbie

Joined: 10/8/2011(UTC)
Posts: 6

Sorry Jake - looks like out posts crossed - was editing at the time.

Any thoughts on "Consent" issue?
Jake  
#23 Posted : Tuesday, March 5, 2013 2:51:53 PM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
Did you figure it out? You'll need to specify additional arguments in your GetAccessToken call. Change this:

Code:
clp.AccessToken = ServerCryptoManager.Instance.GetAccessToken(clp.SessionID, clp.ProcessType, context.User.Identity.Name);


To

Code:
clp.AccessToken = ServerCryptoManager.Instance.GetAccessToken(clp.SessionID, clp.ProcessType, context.User.Identity.Name, SessionPermissions.HostWithoutRemoteConsent | SessionPermissions.RunSharedTool | SessionPermissions.TransferFiles | SessionPermissions.ManageSharedToolbox);
ScreenConnect Team
DaveHTS  
#24 Posted : Friday, August 9, 2013 12:17:42 AM(UTC)
DaveHTS


Rank: Newbie

Joined: 8/9/2013(UTC)
Posts: 7
Location: Illinois

Bringing up this old thread again, but it's pretty useful.

I've got the script working up to the point of:
Code:
            context.Response.Write(url.AbsoluteUri);


I am then trying to use per another thread:
Code:
	    context.Response.AppendHeader("Refresh", "0; URL="+url.AbsoluteUri);


The URL will not get passed by Internet Explorer. It works just fine and brings up a file download prompt in Chrome or FF. If I put a regular URL in the URL= section is passes thru just fine.

The link is perfect - if I copy/paste it into the address bar and go, it auto-joins the session I specified in the tag. I just can't get it to automatically put me there. Is there another way of handling this that will work in IE?
ckinsler  
#25 Posted : Wednesday, August 14, 2013 1:01:33 PM(UTC)
ckinsler


Rank: Newbie

Joined: 8/14/2013(UTC)
Posts: 2

I've put the pieces of code together through these posts, and came up with the following:

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

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

public class LaunchHostClient : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        var sessionTag = context.Request.QueryString["Tag"];
        var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true);

        using (var sessionManager = ServiceChannelPool<ISessionManagerChannel>.Instance.Borrow())
        {
            var sessionSummary = sessionManager.GetSessionSummaries("All Machines", new Dictionary<string, string>(), null).First(ss => string.Equals(ss.Name, sessionTag, StringComparison.InvariantCultureIgnoreCase));

            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);
            
            clp.SessionTitle = sessionTag;

            var url = new Uri(context.Request.Url, "Bin/Elsinore.ScreenConnect.WindowsClient.application" + ClientLaunchParameters.ToQueryString(clp));
            context.Response.Write(url.AbsoluteUri);

        }
    }

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



However, when we attempt to call it, it errors out with “Compiler Error Message: CS1501: No overload for method 'GetAccessToken' takes '4' arguments”

We’re running 3.4.4855.4932, so I’m wondering if one of these calls needs updated for this version?

Thanks for any help you can provide!
DaveHTS  
#26 Posted : Friday, August 16, 2013 4:07:37 PM(UTC)
DaveHTS


Rank: Newbie

Joined: 8/9/2013(UTC)
Posts: 7
Location: Illinois

ckinsler, this is what I have for my launchhostclient.ashx, and it works perfectly except for launching the URL in IE. The GetAccessToken call requires another value at the end, the "DateTime.MinValue".

Code:

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

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

public class LaunchHostClient : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        var sessionTag = context.Request.QueryString["Tag"];
        var relayUri = ServerExtensions.GetRelayUri(ConfigurationManager.AppSettings, HttpContext.Current.Request.Url, true, true);

        using (var sessionManager = ServiceChannelPool<ISessionManagerChannel>.Instance.Borrow())
        {
            var sessionSummary = sessionManager.GetSessionSummaries("All Machines", new Dictionary<string, string>(), null).First(ss => string.Equals(ss.Name, sessionTag, StringComparison.InvariantCultureIgnoreCase));

            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 = sessionTag;

            var url = new Uri(context.Request.Url, "Bin/Elsinore.ScreenConnect.WindowsClient.application" + ClientLaunchParameters.ToQueryString(clp));
            context.Response.Write(url.AbsoluteUri);
            context.Response.AppendHeader("Refresh", "0; URL="+url.AbsoluteUri);
	
	    

        }
    }

    public bool IsReusable { get { return false; } }
}
ckinsler  
#27 Posted : Sunday, August 18, 2013 3:15:25 PM(UTC)
ckinsler


Rank: Newbie

Joined: 8/14/2013(UTC)
Posts: 2

DaveHTS wrote:
ckinsler, this is what I have for my launchhostclient.ashx, and it works perfectly except for launching the URL in IE. The GetAccessToken call requires another value at the end, the "DateTime.MinValue".



Thanks! I tried this code on our install and get the following error when calling it w/ debug set to true:

Server Error in '/' Application.


Sequence contains no matching element
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Sequence contains no matching element

Source Error:


Line 17: using (var sessionManager = ServiceChannelPool<ISessionManagerChannel>.Instance.Borrow())
Line 18: {
Line 19: var sessionSummary = sessionManager.GetSessionSummaries("All Machines", new Dictionary<string, string>(), null).First(ss => string.Equals(ss.Name, sessionTag, StringComparison.InvariantCultureIgnoreCase));
Line 20:
Line 21: var clp = new ClientLaunchParameters();


Source File: c:\Program Files (x86)\ScreenConnect\launchhostclient.ashx Line: 19

Stack Trace:


[InvalidOperationException: Sequence contains no matching element]
System.Linq.Enumerable.First(IEnumerable`1 source, Func`2 predicate) +732233
LaunchHostClient.ProcessRequest(HttpContext context) in c:\Program Files (x86)\ScreenConnect\launchhostclient.ashx:19
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75


DaveHTS  
#28 Posted : Thursday, August 22, 2013 3:33:10 PM(UTC)
DaveHTS


Rank: Newbie

Joined: 8/9/2013(UTC)
Posts: 7
Location: Illinois

No matching element means that you do not have a computer with the machine name you specified.

I tested with a computer named WORKGROUP\DAVEW, so the url I called to direct connect was http://mydomain:8040/LaunchHostClient.ashx?Tag=WORKGROUP\DAVEW

If I try to call the name of a system that is not showing yet in screenconnect under all machines, I get the error you are seeing.

mmitchell  
#29 Posted : Monday, August 26, 2013 4:38:21 PM(UTC)
mmitchell


Rank: Newbie

Joined: 8/26/2013(UTC)
Posts: 3
Location: United States

My company is currently in the process of switching from VNC to this and I was trying to find a way of having a direct URL to connect to a machine which this script does wonderfully.

The script works, but it works with out having to be authenticated to the ScreenConnect server.

Is there an easy way to change this?

For example if the browser does not have a current session this should not work. That way the techs have to be logged into ScreenConnect before the shortcuts in our documentation system would work.
cosys  
#30 Posted : Monday, October 7, 2013 3:39:27 PM(UTC)
cosys


Rank: Advanced Member

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

Joined: 8/26/2013(UTC)
Posts: 35
Location: Florida

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
This is a great add on to SC. Thanks for the effort and it works well with SC 3.4.

So you have an update to the above code for this to work with SC 4.0?

Thanks, again.
Thanks, Philip

Current SC ver. 4.3.6563.5232
Old SC ver. 4.0.5454.5032 - Last Used 05/30/2014
cosys  
#31 Posted : Monday, October 7, 2013 8:39:13 PM(UTC)
cosys


Rank: Advanced Member

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

Joined: 8/26/2013(UTC)
Posts: 35
Location: Florida

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
Here's the error I get running the code under SC 4.0 (Code ran fine on SC 3.4). Any help to resolve this error would be appreciated!
Quote:

Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1061: 'Elsinore.ScreenConnect.ISessionManagerChannel' does not contain a definition for 'GetSessionSummaries' and no extension method 'GetSessionSummaries' accepting a first argument of type 'Elsinore.ScreenConnect.ISessionManagerChannel' could be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 17: using (var sessionManager = Elsinore.ScreenConnect.ServiceChannelPool<Elsinore.ScreenConnect.ISessionManagerChannel>.Instance.Borrow())
Line 18: {
Line 19: var sessionSummary = sessionManager.GetSessionSummaries("All Machines", new Dictionary<string, string>(), null).First(ss => string.Equals(ss.Name, sessionTag, StringComparison.InvariantCultureIgnoreCase));
Line 20:
Line 21: var clp = new ClientLaunchParameters();

Source File: c:\Program Files (x86)\ScreenConnect\LaunchHostClient.ashx Line: 19 (This is the error line)

Edited by user Tuesday, October 8, 2013 9:11:20 AM(UTC)  | Reason: Not specified

Thanks, Philip

Current SC ver. 4.3.6563.5232
Old SC ver. 4.0.5454.5032 - Last Used 05/30/2014
cosys  
#32 Posted : Thursday, October 17, 2013 11:27:03 AM(UTC)
cosys


Rank: Advanced Member

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

Joined: 8/26/2013(UTC)
Posts: 35
Location: Florida

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
Here is more info on the error with SC 4.0
Quote:
C:\Windows\system32> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\Program Files (x86)\ScreenConnect\Bin\Elsinore.ScreenConnect.Server.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Data.Linq.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll" /R:"C:\Program Files (x86)\ScreenConnect\Bin\Elsinore.ScreenConnect.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\Program Files (x86)\ScreenConnect\Bin\Elsinore.ScreenConnect.Client.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\Program Files (x86)\ScreenConnect\Bin\Elsinore.ScreenConnect.Windows.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\35c504ff\e26c2568\App_GlobalResources.kyts6j3m.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\Program Files (x86)\ScreenConnect\Bin\Elsinore.ScreenConnect.Core.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\Program Files (x86)\ScreenConnect\Bin\Elsinore.ScreenConnect.WindowsServer.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /out:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\35c504ff\e26c2568\App_Web_launchhostclient.ashx.cdcab7d2.zh__jik6.dll" /debug- /optimize+ /w:4 /nowarn:1659;1699;1701;612;618 /nowarn:1685 /warnaserror- "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\35c504ff\e26c2568\App_Web_launchhostclient.ashx.cdcab7d2.zh__jik6.0.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\35c504ff\e26c2568\App_Web_launchhostclient.ashx.cdcab7d2.zh__jik6.1.cs"


Microsoft (R) Visual C# Compiler version 4.0.30319.17929

for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.

c:\Program Files (x86)\ScreenConnect\LaunchHostClient.ashx(19,49): error CS1061: 'Elsinore.ScreenConnect.ISessionManagerChannel' does not contain a definition for 'GetSessionSummaries' and no extension method 'GetSessionSummaries' accepting a first argument of type 'Elsinore.ScreenConnect.ISessionManagerChannel' could be found (are you missing a using directive or an assembly reference?)
Thanks, Philip

Current SC ver. 4.3.6563.5232
Old SC ver. 4.0.5454.5032 - Last Used 05/30/2014
Jake  
#33 Posted : Thursday, October 17, 2013 12:00:30 PM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
change references to GetSessionSummaries: GetSessionSummaries->GetSessions
ScreenConnect Team
thanks 1 user thanked Jake for this useful post.
cosys on 10/17/2013(UTC)
cosys  
#34 Posted : Thursday, October 17, 2013 12:15:56 PM(UTC)
cosys


Rank: Advanced Member

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

Joined: 8/26/2013(UTC)
Posts: 35
Location: Florida

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
Thanks, Jake! It worked.

Correct line 19 for SC 4.0 is ..
Quote:
var sessionSummary = sessionManager.GetSessions("All Machines", new Dictionary<string, string>(), null).First(ss => string.Equals(ss.Name, sessionTag, StringComparison.InvariantCultureIgnoreCase));
Thanks, Philip

Current SC ver. 4.3.6563.5232
Old SC ver. 4.0.5454.5032 - Last Used 05/30/2014
ben  
#35 Posted : Monday, December 9, 2013 6:35:55 AM(UTC)
ben


Rank: Member

Joined: 11/22/2013(UTC)
Posts: 14

Thanks: 1 times
As evolved from original content here's the piece of code I'm trying to use right now:
Code:

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

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

public class LaunchHostClient : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        var sessionTag = context.Request.QueryString["Tag"];
        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 => string.Equals(ss.Name, sessionTag, StringComparison.InvariantCultureIgnoreCase));
            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);
            
            clp.SessionTitle = sessionTag;

            var url = new Uri(context.Request.Url, "Bin/Elsinore.ScreenConnect.WindowsClient.application" + ClientLaunchParameters.ToQueryString(clp));
            context.Response.Write(url.AbsoluteUri);
        }
    }

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


sessionManager.GetSession is updated as suggested by Jake but I'm still getting error on that line, here's:
Quote:

System.InvalidOperationException
Sequence contains no matching element

Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Core.
Exception stack trace:
at System.Linq.Enumerable.First[Session] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
at System.Linq.Enumerable.First[Session] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
at LaunchHostClient.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator3.MoveNext () [0x00000] in <filename unknown>:0
at System.Web.HttpApplication.Tick () [0x00000] in <filename unknown>:0


Line 19 (var sessionSummary = ...) is where I'm getting the error
Linux CentOS 6.4, AMD64, ScreenConnect version 4.0.5552.5051

Any hints ?

... and an additional request related to the correct client OS detection, I have seen:
var url = new Uri(context.Request.Url, "Bin/Elsinore.ScreenConnect.WindowsClient.application" + ClientLaunchParameters.ToQueryString(clp));
but inside Jake's original post there is something like:
var url = new Uri(context.Request.Url, "Bin/Elsinore.ScreenConnect.HostClient.application" + ClientLaunchParameters.ToQueryString(clp));
Which is the correct one ? I'd like to use this url from a Mac too

Thanks

Ben
Alexander  
#36 Posted : Monday, December 9, 2013 10:41:49 AM(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)
I guess the first question to ask is: do you in fact have a session with the name you're passing in? That error looks like it could just be caused by a typo or something.
ScreenConnect Team
ben  
#37 Posted : Monday, December 9, 2013 12:20:09 PM(UTC)
ben


Rank: Member

Joined: 11/22/2013(UTC)
Posts: 14

Thanks: 1 times
Just found it, this is the good one:
Quote:
var sessionSummary = sessionManager.GetSessions("All Sessions", new Dictionary<string, string>(), null).First(ss => string.Equals(ss.Name, sessionTag, StringComparison.InvariantCultureIgnoreCase));


is not All Machines but All Sessions
This seems to be working


Now I'm trying to solve my second question, this line:
Code:
var url = new Uri(context.Request.Url, "Bin/Elsinore.ScreenConnect.ClientBootstrap.exe" + ClientLaunchParameters.ToQueryString(clp));

seems to be good on WinXP 32Bit.
but:
Code:
var url = new Uri(context.Request.Url, "Bin/Elsinore.ScreenConnect.WindowsClient.application" + ClientLaunchParameters.ToQueryString(clp));

doesn't work (no SC plugins installed on the browser).

Is there a way to detect the client operating system and change this part with the right string ? I'm running into troubles because we'd like to use it in a mixed environment: Win 32/64, OS-X and few linux machines as well.
This script is nice but it's platform dependent. How can the /Host.aspx detect the right platform inside the real web interface ? User-Agent ?
Is this something I must provide on the server side with a proper LaunchHostClient.ashx page or something I can delegate to some sort of internal SC API ?

Thanks in advance for your reply
Kind Regards

Ben
Alexander  
#38 Posted : Monday, December 9, 2013 3:57:50 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)
Well, for cross-platform, it might be better to just use a different url entirely: if you go to your host page and click on the session you want to join, then get the url and add "/Join" to the end, you should get a url that looks something like this: support.yourcompany.com/Host#All%20Machines//7832e30f-bf9d-4350-94ed/Join, which you can open from the command line to connect to that session. On the other hand, this approach will open up a browser window, and of course it uses guids to identify sessions rather than names.
ScreenConnect Team
ben  
#39 Posted : Tuesday, December 10, 2013 11:10:40 AM(UTC)
ben


Rank: Member

Joined: 11/22/2013(UTC)
Posts: 14

Thanks: 1 times
I'm already using the "/Join" URI for joining a session as guest. It works fine with Windows and OS-X.
My problem is attending to an already created session as Host with different platforms (Win32-64, OS-X). I'd like to reproduce the behaviour of the JOIN button when you're logged in and you want to start a session as Host.

Alexander  
#40 Posted : Wednesday, December 11, 2013 10:37:19 AM(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)
Huh… it should work for joining a session as host. What sort of url are you using?
ScreenConnect Team
mlsmith  
#41 Posted : Wednesday, December 11, 2013 11:27:05 AM(UTC)
mlsmith


Rank: Member

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

Joined: 12/11/2013(UTC)
Posts: 14
Location: Maumelle, AR

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
I would be very interested in this functionality as well. I would like to integrate it with N-Able. So if you guy's could build a small app/provide a simple solution for non-programmers to utilize that would be awesome.

We're evaluating ScreenConnect at the moment and having this functionality would put SC over the top. we would be using it to connect remote into over 1500 computers.

--Mike
JoshK  
#42 Posted : Saturday, December 14, 2013 6:51:28 PM(UTC)
JoshK


Rank: Newbie

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

Joined: 12/14/2013(UTC)
Posts: 5
Location: USA

Was thanked: 1 time(s) in 1 post(s)
I agree that this functionality would be great. We are using Labtech and trying to make it as seamless as possible. We are also evaluating Screen Connect right now for several thousand machines, so scaling the management of the system is a big deal to us. As is reporting and a few other things...

For us, Labtech knows the PC name and group name if we create them consistently during scripted deployment. If we could launch a URL that contained the unique PC name with a /join at the end, that would be perfect. Now we can get it to take us to the site and show us the machine name, but the admin has to then join the session manually. Less steps would be great. We just don't have the GUID in Labtech to be able to pass on to the URL. We only have the PC name. I saw a post about using ORCA and customizing the name, which would make them unique for us because we could make the machine name be ClientName.LocationName.PCName. It also makes it easier for us to sort that way.

Josh
Alexander  
#43 Posted : Wednesday, December 18, 2013 12:26:40 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)
I just made a post about getting the GUID from the session name over here: http://forum.screenconne...om-my-crm.aspx#post11302
ScreenConnect Team
JoshK  
#44 Posted : Thursday, December 19, 2013 12:20:23 AM(UTC)
JoshK


Rank: Newbie

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

Joined: 12/14/2013(UTC)
Posts: 5
Location: USA

Was thanked: 1 time(s) in 1 post(s)
It looks like the GUID is in the registry on a PC too, but you have to parse through it. It is after the S= in HKLM\\system\currentcontrolset\screenconnect client(ID) in the ImagePath key. It is a long string, but the GUID is in there. That could be another way to get the information.
myoung  
#45 Posted : Tuesday, February 25, 2014 8:11:29 PM(UTC)
myoung


Rank: Member

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

Joined: 2/21/2014(UTC)
Posts: 16
United States

Thanks: 3 times
Was thanked: 3 time(s) in 2 post(s)
Alexander, do you know if it's possible to launch directly to a session if you have the GUID of the machine? Currently we are using the support.yourcompany.com/Host#All%20Machines//GUID_Here/Join method but this spawns a browser window on each connection from our CRM. Is it possible to modify the above LaunchHostClient.ashx file to utilize the GUID instead of the machine name? I've tried passing the /Join URL directly with rundll32.exe with no luck and I'm assuming this would still need to be accomplished with curl...
Alexander  
#46 Posted : Wednesday, February 26, 2014 3:15:57 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, it should just be a question of changing these three lines, I believe:
Code:
var sessionID = new Guid(context.Request.QueryString["Tag"]);

Code:
var sessionSummary = sessionManager.GetSessions("All Machines", new Dictionary<string, string>(), null).First(ss => ss.SessionID == sessionID);

Code:
clp.SessionTitle = sessionSummary.Name;
ScreenConnect Team
thanks 1 user thanked Alexander for this useful post.
myoung on 2/26/2014(UTC)
myoung  
#47 Posted : Wednesday, February 26, 2014 4:59:17 PM(UTC)
myoung


Rank: Member

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

Joined: 2/21/2014(UTC)
Posts: 16
United States

Thanks: 3 times
Was thanked: 3 time(s) in 2 post(s)
Thanks, Alexander! That worked perfectly. The only issue I am having is that it allows the session to open even if the user is currently logged out (like mmitchell mentioned in post 29). I see at one point a line regarding "asserting permission" in the handler was mentioned but I don't see that anywhere in any of the code samples. We couldn't implement this it doesn't require authentication first for security purposes. Can you see anything obvious from the following code that could be added to force an authentication request first?

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

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

public class LaunchHostClient : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var sessionID = new Guid(context.Request.QueryString["Tag"]);
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 == 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/Elsinore.ScreenConnect.WindowsClient.application" + ClientLaunchParameters.ToQueryString(clp));
context.Response.Write(url.AbsoluteUri);
context.Response.AppendHeader("Refresh", "0; URL="+url.AbsoluteUri);
    
     

}
}

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

Edited by user Wednesday, February 26, 2014 4:59:49 PM(UTC)  | Reason: Not specified

Alexander  
#48 Posted : Wednesday, February 26, 2014 11:28:52 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)
Something like this should do it, I believe:
Code:
Permissions.AssertPermission(PermissionInfo.JoinSessionPermission, false);
ScreenConnect Team
Alexander  
#49 Posted : Monday, September 8, 2014 5:40:55 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)
Since I've been linking to this thread recently, here's the version for 4.4, including a check for permissions.

LaunchHostClient.ashx
Code:
<%@ WebHandler Language="C#" Class="LaunchHostClient" %>
 
using System;
using System.Web;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using Elsinore.ScreenConnect;

public class LaunchHostClient : IHttpHandler
{
	public void ProcessRequest(HttpContext context)
	{
		Permissions.AssertPermission(PermissionInfo.JoinSessionPermission, false);
		
		var sessionTag = context.Request.QueryString["Tag"];
		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 => string.Equals(ss.Name, sessionTag, StringComparison.InvariantCultureIgnoreCase));

			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 = sessionTag;

			var url = new Uri(context.Request.Url, "Bin/Elsinore.ScreenConnect.WindowsClient.application" + ClientLaunchParameters.ToQueryString(clp));
			context.Response.Write(url.AbsoluteUri);
		}
	}

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


launch.cmd
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:&=^&%


Run with: launch.cmd support.myserver.com 8040 MYPCNAME username password
Needs curl.exe, like the one attached to this post.

Edited by user Monday, September 8, 2014 5:41:35 PM(UTC)  | Reason: Not specified

ScreenConnect Team
thanks 2 users thanked Alexander for this useful post.
eastrand on 9/8/2014(UTC), dszp on 9/18/2014(UTC)
Alexander  
#50 Posted : Monday, October 27, 2014 5:49:53 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)
So, the ScreenConnector extension does much the same thing as this, and its equivalent of LaunchHostClient.ashx is better able to handle various situations, like different permissions.
If you have it installed (even if it isn't enabled), this launch.cmd will use that:
Code:
for /f %%A IN ('curl.exe -u %4:%5 http://%1:%2/App_Extensions/850c08be-d904-48d4-977a-5c2fcb277fd4/Service.ashx/GetLaunchUrl/%3') DO SET URL=%%A
SET UNQUOTED_URL=%URL:"=%
rundll32 dfshim.dll,ShOpenVerbApplication %UNQUOTED_URL:\u0026=^&%
ScreenConnect Team
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 Pages12>
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.