Sun Ray as a Windows Based Terminal using RDesktop


Much to the chagrin of a certain hockey playing CEO and a pony tailed President (not to mention any other long time Sun employee), one of the most popular uses for Sun Ray Thin Clients is to have them display full screen windows desktops using either Citrix or RDP. In this post I'll give an example script or two on how to combine Controlled Access Mode (Kiosk/CAM) with RDesktop to turn the Sun Ray into a Windows Based Terminal. Once you use a Sun Ray as a WBT and compare the ease and flexibility compared to other thin clients, you'll see it's a "wise" choice.

Where to get Rdesktop? If  you're geeky enough, you can compile the source from Rdesktop.org.  Otherwise I'd recommend getting it from Sunfreeware.com, Blastwave.org, or the Sun Ray Software Companion CD.

NOTE: Currently Controlled Access Mode is only available on Sun Ray Server installations running on Solaris (SPARC or x86).

Now you can make this real simple, or you can get a little more elaborate.  A simple method can be seen by creating a CAM application to point to a script such as the one in this post.

But let's get a bit more elaborate in this example. 

First a little background.  While Microsoft has support for load balancing in RDP via the Windows Network Load Balancing  Service, there are quite a few short comings.  Brian Madden has an excellent paper on NLB, be sure to read it.  To make up for some of these short comings, you must use the Terminal Server Session Directory.  The big draw back to that is cost since the Session Directory requires that your terminal servers run Windows 2003 Enterprise edition (read 3X the cost of standard Server).  Even with all this, rdesktop does not currently support either as it is missing support for the redirection bit from the terminal server. So for now the point of using either with rdesktop is moot.

This example script will spread out the connections to each Windows terminal server listed.  It is only based on the number of connections to each Windows terminal servers from a single Sun Ray Server, no server load is taken into account so it is really not true load balancing.  However it does a very good job of  making sure each Windows terminal server gets an equal amount of  connections.

Why not just do a simple DNS round robin? Trying to do a typical Round Robin from a multiuser server does not work since each users first request will go to the first entry in DNS Server. This will result in all users going to the first Windows Terminal Server listed, only on that users second request will they be sent to the second WTS.

First we need to ensure that we've enabled Controlled Access Mode when we ran utconfig, then we need to enable CAM for either non-smart card or smart card users or both by changing the Sun Ray Policy.

We will then define a CAM Application.  This CAM application will call our first script which we will call /opt/SUNWutWBT/WBTStart1

The purpose of this script is to check if your terminal servers are reachable (via ping), count the number of connections to each terminal server, then send your Sun Ray to the terminal server with the least number of connections.

#!/bin/sh
# WBTStart1
# Simple Load Balancing Script for RDesktop
# Written by Craig Bender, Sun Ray Engineering
#
# Enter Your Windows Terminal Servers Below in the WTSARRAY Section
# in a space delimited format as shown below.
#
# Note that they must match names you connect RDesktop to.
#
# Hostnames entered must be resolved by a Solaris Naming Service
# (i.e. hosts file or DNS)
#
#
# Edit the WTSARRAY line below with the names of your terminal servers
#
WTSARRAY="wints1.yourorg.com wints2.yourorg.com"
#
#
# Server Check and Calculation Area - Do not edit below this line
#
set -x
for i in `echo $WTSARRAY`
 do
   /usr/sbin/ping $i 2
    if [ $? -eq 0 ]
     then
     echo $i is pingable
      if [ $LBWTSARRAY ]
       then
       LBWTSARRAY=$LBWTSARRAY:$i
       export LBWTSARRAY
       else
       LBWTSARRAY=$i
       export LBWTSARRAY
      fi
    else echo $i is not reachable
    echo $i will not be used for load balancing
   fi
done
echo Will check `echo $LBWTSARRAY|awk -F: '{ for (i = NF; i > 0; --i) print $i }'` to see which has the fewest connections.
LOWEST=999
export LOWEST
for i in `echo $LBWTSARRAY|awk -F: '{ for (i = NF; i > 0; --i) print $i }'`
do
COUNT=`ps -ef |grep $i|grep -v grep|wc -l`
 if [ $COUNT -lt $LOWEST ] && [ $COUNT -ge 0 ]
 then
  echo $i has $COUNT connections
  LOWEST=$COUNT
  WTS=$i
 else
  echo $i has the same or more connections than other servers
 fi
done
echo Will connect to $WTS that has $LOWEST connections
/opt/SUNWutWBT/WBTStart2 $WTS
# End of Script

Now we need to create the second script, which we will call /opt/SUNWutWBT/WBTStart2.  The only reason why we have this going into a separate script is so that we can properly count the number of times a Windows Terminal Server is being called.  If we just embedded the rdestkop command into this script, the ps utility would truncate the name of the Windows Terminal Server since RDesktop expects the terminal server to connect to as the last argument.  This would cause our counting method to fail.

Feel free to add other options as supported by RDesktop to this script, including disk mapping, printer redirection, serial port mapping, etc.

#!/bin/sh
# WBTStart2
# Written by Craig Bender, Sun Ray Engineering
#

# Fix alt+printscreen for older versions of rdesktop
/usr/openwin/bin/xmodmap -e 'keycode 77 = 0xff61'
# Turn numlock on
/usr/openwin/bin/xset led 1
# Launch rdesktop
/opt/SUNWrdp/bin/rdesktop -f -a 24 -r sound -u "" $1


Now all we need to do is configure CAM to Start Rdesktop

1. Open Sun Ray Administration Web Page and login
    a. http://localhost:1660
2. Click Controlled Access Mode
3. Click Add/Edit Applications
4. Enter SUNWutWBT for Application Name
5. Enter SUNWutWBT for Application Menu Label
6. Enter /opt/SUNWutWBT/WBTStart1 for the Path of Application
    a. Select an attribute. Select default to test, then move to Critical once you know everything works.
7. Click Add New
8. Click Select Applications
9. Click SUNWutWBT, click the Add>> button
10. Click Confirm, click Confirm Settings

Finally we need to choose a policy for CAM to operate under

1. Click Admin from the Sun Ray Administration Web page
2. Click Policy
3. Ensure that your policy reflects your use of smart cards
4. Ensure that Controlled Access Mode is selected
5. Click Restart Services
6. Choose group or local depending on your failover group setup
7. Choose Restart

Finished!

All Sun Rays should now come up as a Windows Based Terminal using Rdesktop depending on your policy.
Comments:

This is a wonder thing. However i am lookout for one other script / way to control the timings on Kiosk Mode . Basically on shared Internet cafe applications, is there a way to control how long a card can be used ? If a user buys a browsing time of 1 hour , I want a scirpt which will disable the card after a hour . Please let me know if you know any such application even if I have to Buy .

Posted by Murugan on February 17, 2006 at 05:11 PM PST #

i'm on a sunray. Couldn't find rdesktop. do we have to build it ourself? if so, it ain't fun. It's not that I can't make 'em, it's my (SunRay server) admin that won't let me add/install new apps. bummer!

Posted by ben on June 26, 2008 at 04:39 AM PDT #

Hi Ben, you can grab rdesktop from various sources like Sunfreeware.com.

But this article is over two years old and Sun now has it's own rdp client, SUNWuttsc. Click on the Sun Ray Software 4 button, sign in to sun.com, then you can choose to download the Sun Ray Connector for Windows.

http://www.sun.com/software/sunray/getit.jsp

Posted by Thin Guy on June 28, 2008 at 03:58 AM PDT #

Hi,

is there an possibility to set up the Windows Connector (the one from Sun, Version 2.2) in that way, that it appears on the login screen of sun? (you know, options, session: there you can choose the java desktop system, the cde, failsafe or users last desktop. i would need an "windows connector button" there which you can check and which would ask then for the ip of the remotedesktop you want to use - instead of the username. i would need that badly for our university, as we networkers use the suns for access to unix, but do need "direct" access to our windows remote desktops aswell - and that solution would be just great!)

Posted by Nico on July 28, 2009 at 11:39 PM PDT #

Post a Comment:
Comments are closed for this entry.
About

Think Thin is a collection of bloggers that work with Oracle's Virtual Desktop portfolio of products.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today