Elsinore

User Forum

www.screenconnect.com
Welcome Guest Search | Active Topics | Log In | Register

Tag as favorite
integrating ScreenConnect into website using Ajax calls
krszeto
#1 Posted : Tuesday, January 17, 2012 5:53:02 PM
Rank: Newbie
Joined: 1/17/2012
Posts: 8
Location: US
Hi,

We currently have ScreenConnect installed on one of our servers and are using it to provide service to our clients. However, the current setup forces us to forward all of our clients to that specific server, and to host/guest pages that really aren’t part of our site.

I am currently trying to integrate ScreenConnect 2.3 into our site, and was hoping to get some feedback and help. Looking through the page code, it seemed like everything relied on Service.ashx, and the pages would make ajax calls to the service methods. So we were thinking that we could install ScreenConnect on an app server, and have our website code make the ajax calls to that server directly (eliminating the need to forward customers to the host/guest pages).

However, so far, I have failed to make this work. The ajax call from the client side is being made without error, but nothing on the server side seems to be happening. My suspicion is that I am failing a security check. If that is the case, what would be the best way to handle that. I would really appreciate any help/advice you can offer.

I would also be interested in any other suggestions on how we should integrate ScreenConnect with our site. I understand you have an iframe option, but given the amount of customization we have done, and would like to do to ScreenConnect, we feel that an iframe is not the best solution.

Thanks
Jake Morgan
#2 Posted : Tuesday, January 17, 2012 7:20:08 PM
Rank: Administration
Joined: 4/9/2010
Posts: 871
You should be able to call into the Service.ashx methods. If nothing else you should get errors. Have you tried debugging on the browser side? Chrome and IE both have debug consoles you can popup with the F12 key. Firefox has Firebug that you can install for the same functionality.
krszeto
#3 Posted : Tuesday, January 17, 2012 7:37:57 PM
Rank: Newbie
Joined: 1/17/2012
Posts: 8
Location: US
yes i have debugged on the browser side, and i am not getting any errors, and the invokeService method (createSession in this case) is returning a Sys.Net.WebRequest object. The call is hitting Service.ashx, but nothing is happening. The reason i suspect it is a security issue is that the _resultObject of the return object's _executor property is null. If i am on the ScreenConnect Host page and am signed in, it is not null, but if i was logged out, _resultObject is null. So maybe i need to have a method that authenticates the user, before executing other service methods?

Obviously i can't be sure that it is a security issue since i can't step through the Service.ashx code, but that is my guess. Any help on this issue would be much appreciated
Jake Morgan
#4 Posted : Tuesday, January 17, 2012 7:45:06 PM
Rank: Administration
Joined: 4/9/2010
Posts: 871
AJAX is asynchronous-- that's what the "A" stands for. You'll have to provide a callback method to the invokeService function. It'll call back with the results. You can also provide a separate callback for when an error occurs. One of them should be getting called.
krszeto
#5 Posted : Tuesday, January 17, 2012 7:58:53 PM
Rank: Newbie
Joined: 1/17/2012
Posts: 8
Location: US
i know that it is asynchronus, what i'm saying is i'm not getting anything back at all. I would do 2 exactly identical javascript calls in the console, one on my site page, one on the host page. both ajax calls are made to the url "http://xxx/Service.ashx", one will succeed and the other will get absolutely nothing.

Another difference i have found in the 2 results is, one's _responseAvailable is false, and the other's is true
Jake Morgan
#6 Posted : Tuesday, January 17, 2012 9:43:19 PM
Rank: Administration
Joined: 4/9/2010
Posts: 871
Which of your callbacks is it calling? onSuccess or onError? You should be able to step through the code and you should see the call on the "Network" tab in Chrome. It should show the HTTP request/response.
krszeto
#7 Posted : Wednesday, January 18, 2012 5:53:36 PM
Rank: Newbie
Joined: 1/17/2012
Posts: 8
Location: US
My apologies, I failed to realize that I was running into the same origin policy.

I am currently looking into cross origin resource sharing, would you happen to have any tips on how to implement it in the ScreenConnect code/configs?

The backup solution would be to use a reverse proxy, but i would very much like to avoid that if possible
Jake Morgan
#8 Posted : Wednesday, January 18, 2012 8:54:28 PM
Rank: Administration
Joined: 4/9/2010
Posts: 871
we support JSONP for cross site ... i think you specify the arguments as path elements then provide a callback like this http://yourstuff/Service.ashx/arg1/arg2/arg3?callback=myJavascriptFunctionName
krszeto
#9 Posted : Thursday, January 19, 2012 3:11:35 AM
Rank: Newbie
Joined: 1/17/2012
Posts: 8
Location: US
Thank you Jake, that worked perfectly. I believe i really only have 1 problem/question left:

What would be the best way to handle/bypass the user authentication. We have users log in at our site already, so we would really like to avoid users from needing to log in twice.

I guess I would need to write a log in method? What would that method look like?
Jake Morgan
#10 Posted : Thursday, January 19, 2012 12:42:34 PM
Rank: Administration
Joined: 4/9/2010
Posts: 871
Are you using forms or windows authentication?
Jake Morgan
#11 Posted : Thursday, January 19, 2012 2:03:49 PM
Rank: Administration
Joined: 4/9/2010
Posts: 871
Here is a login method for forms authentication you can put in your service.ashx:

Code:
        public void Login(string userName, string password)
        {
            if (System.Web.Security.FormsAuthentication.Authenticate(userName, password))
                System.Web.Security.FormsAuthentication.SetAuthCookie(userName, false);
        }
krszeto
#12 Posted : Saturday, January 21, 2012 12:37:54 AM
Rank: Newbie
Joined: 1/17/2012
Posts: 8
Location: US
Thanks Jake, this has been very useful. I'm sorry that this leads me to another question

so if i made this service call from my site code, i would need to send over an unencrypted password. Is there any way that we could have ScreenConnect use our security system? I know this may not be possible, but the ideal scenario would be that users would log into our site, and could use ScreenConnect as if they are also logged into ScreenConnect with their own account (without needing to log in a 2nd time), without any major security risks. ie. user A can't interfere user B's sessions, passwords are secured, people without an account on our site can't login/access host methods.

sorry that this discussion seems never ending, i really appreciate your help
Jake Morgan
#13 Posted : Saturday, January 21, 2012 1:38:26 AM
Rank: Administration
Joined: 4/9/2010
Posts: 871
How does your auth work? What's the backend? Will the user have a cookie? Or what if not a cookie?
krszeto
#14 Posted : Saturday, January 21, 2012 1:56:49 AM
Rank: Newbie
Joined: 1/17/2012
Posts: 8
Location: US
the user has a cookie, i'm still waiting to hear back from the developer responsible for our security system for more details on the backend implementation.
Jake Morgan
#15 Posted : Saturday, January 21, 2012 2:00:00 AM
Rank: Administration
Joined: 4/9/2010
Posts: 871
Regardless of what it is, you should be fine. But get ready to write some C#. You'll likely need to provide an implementation for an ASP.NET RoleProvider and MembershipProvider.
krszeto
#16 Posted : Saturday, January 21, 2012 2:10:05 AM
Rank: Newbie
Joined: 1/17/2012
Posts: 8
Location: US
I am fine with writing C#, do you have any guidelines on what needs to be done, what specific methods i will need to override, and where i should set up those files in ScreenConnect/our site? our site uses C#, but we don't really utilize the built in .Net framework that much, so i am not familiar with those 2 classes. In the meantime, i will look up the documentation online
Jake Morgan
#17 Posted : Wednesday, January 25, 2012 10:03:06 PM
Rank: Administration
Joined: 4/9/2010
Posts: 871
Try creating a System.Web.IHttpModule called CustomAuthenticationModule that subscribes to the AuthenticateRequest event. In your handler you need to set the HttpContext.Current.User principal, probably to a GenericPrincipal with the username and roles they have in your system.

Implement a role provider CustomRoleProvider deriving from Elsinore.ScreenConnect.ReadOnlyRoleProvider. Just override the GetRolesForUser method. This method will be called with the value from HttpContext.Current.User.Identity.Name that you should have populated from your module.

I guess you'll want to change this:

Code:
<authentication mode="Forms">


to this:

Code:
<authentication mode="None">


Put the cs files for both your http module and your role provider in a directory called App_Code off your install root.

Your role manager section should probably look like this:

Code:
  <roleManager enabled="true" defaultProvider="Custom">
   <providers>
    <clear />
    <add name="Forms" type="Elsinore.ScreenConnect.XmlRoleProvider" />
    <add name="Windows" type="Elsinore.ScreenConnect.WindowsRoleProvider" />
    <add name="Custom" type="Elsinore.ScreenConnect.CustomRoleProvider" />
   </providers>
  </roleManager>


Your httpModules section should add your module:

Code:
  <httpModules>
   <remove name="FileAuthorization" />
   <remove name="FormsAuthentication" />
   <add name="BasicMembershipFormsAuthenticationModule" type="Elsinore.ScreenConnect.BasicMembershipFormsAuthenticationModule, Elsinore.ScreenConnect.Web" />
   <add name="DisplayWindowsAuthenticationModule" type="Elsinore.ScreenConnect.DisplayWindowsAuthenticationModule, Elsinore.ScreenConnect.Web" />
   <add name="CacheBusterModule" type="Elsinore.ScreenConnect.CacheBusterModule, Elsinore.ScreenConnect.Web" />
   <add name="DemandAuthenticationModule" type="Elsinore.ScreenConnect.DemandAuthenticationModule, Elsinore.ScreenConnect.Web" />
   <add name="SetupModule" type="Elsinore.ScreenConnect.SetupModule, Elsinore.ScreenConnect.Web" />
   <add name="CompressionModule" type="Elsinore.ScreenConnect.CompressionModule, Elsinore.ScreenConnect.Web" />
   <add name="CustomAuthenticationModule" type="Elsinore.ScreenConnect.CustomAuthenticationModule" />
  </httpModules>
jbrisko
#18 Posted : Sunday, April 08, 2012 4:31:40 AM
Rank: Newbie
Joined: 4/8/2012
Posts: 1
I'm looking to do some work with JSONP but am having trouble getting my service to return any pertinent data. Could one of you post a sample of your js code? I would appreciate it!

Thanks
mayala
#19 Posted : Tuesday, April 24, 2012 9:27:19 PM
Rank: Newbie
Joined: 4/24/2012
Posts: 1
Location: New York
jbrisko wrote:
I'm looking to do some work with JSONP but am having trouble getting my service to return any pertinent data. Could one of you post a sample of your js code? I would appreciate it!

Thanks


Same here, haven't had much luck. Any examples would be appreciated.
Users browsing this topic
Guest
Tag as favorite
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.