You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by PatrickH <pa...@gmail.com> on 2019/02/21 09:42:27 UTC

Show active session through VNC

Hello, 
I'm using a customised Guacamole web app, to connect via VNC. The web app retrieves computers, users from a specific AD domain. And for each computer (Windows 10), it shows the connected user (only one session at a time). 
Now, with Guacamole I just want to show the active session on the remote computer, with no interaction, just a view only. 
I do have the user connected, the session ID and I want to open the active session to show in a new browser window. 
Is it possible ? 

Here's the javascript: 
. 
. 
. 
 /*
<![CDATA[ */
            $.urlParam = function(name) {
                var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);

                if (results==null){
                    return null;
                }
                else{
                    return decodeURI(results[1]) || 0;
                }
            }

            var errMessage = "Problème lors de la connexion."
            var computerName = $.urlParam('computerName');
            var connectionParams = 'computerName=' + computerName;

            if (computerName && computerName != null) {
                // Get display div from document
                var display = $('#display');

                // Instantiate client, using an HTTP tunnel for communications.
                var guac = new Guacamole.Client(new Guacamole.HTTPTunnel("connect"));

                // Mouse
                var mouse = new Guacamole.Mouse(guac.getDisplay().getElement());

                mouse.onmousedown = 
                mouse.onmouseup   =
                mouse.onmousemove = function(mouseState) {
                    guac.sendMouseState(mouseState);
                };

                // Add client to display div
                display.appendChild(guac.getDisplay().getElement());

                // Error handler
                guac.onerror = function(error) {alert(errMessage);};

                // Connect
                guac.connect(connectionParams);

                // Disconnect on close
                window.onunload = function() {guac.disconnect();}
            } else {
                alert('Aucun ordinateur renseigné !');
            }
        /* ]]>
 */ 
. 
. 
. 
And the servlet code: 
    @Override 
    protected GuacamoleTunnel doConnect(HttpServletRequest request) throws GuacamoleException { 
        // Logging 
        ServletContext context = getServletContext(); 

        // Préparation de la configuration 
        GuacamoleConfiguration config = new GuacamoleConfiguration(); 
        config.setProtocol("vnc"); 
        config.setParameter("username", request.getParameter("userName")); 

        config.setParameter("hostname", request.getParameter("computerName")); 
        config.setParameter("port", System.getProperty("consoleDe.vncserver.port")); 

        context.log("Paramètres reçus"); 
        context.log("hostname: " + request.getParameter("computerName")); 
        context.log("port VNC: " + System.getProperty("consoleDe.vncserver.port")); 
        context.log("Guacamole adresse: " + System.getProperty("consoleDe.guacamole.address")); 
        context.log("Guacamole port: " + System.getProperty("consoleDe.guacamole.port")); 

        GuacamoleSocket socket = new ConfiguredGuacamoleSocket( 
                new InetGuacamoleSocket( 
                    System.getProperty("consoleDe.guacamole.address"), 
                    Integer.parseInt(System.getProperty("consoleDe.guacamole.port"))), 
                config 
        ); 

        // Return a new tunnel which uses the connected socket 
        return new SimpleGuacamoleTunnel(socket); 
    } 

Thanks for your help