Exercise 7-1: Using Terminal Services


Exercise 7-1: Using Terminal Services

Integrating Microsoft Terminal Services with SPS provides a good mechanism for accessing legacy applications directly from the portal. Such a solution could mean a significant reduction in client-side installations and maintenance for older applications. In this exercise, you will set up Terminal Services and create a web part to access an application.

Setting Up Terminal Services

Before you can set up Terminal Services, you need to provide a separate server. Do not attempt to install Terminal Services on SPSPortal or SPSController because the installation can interfere with other projects in the book. I have solved this problem by creating a VMWare session named TS2K3 . If you are not using a server consolidation product like VMWare, however, you will need a server capable of running Windows 2003.

Installing Terminal Services

Terminal Services should always be installed on the server as the first order of business after the operating system is installed. This is because applications that you want to access from Terminal Services must be installed after the server is configured or they will not be available. The rest of the exercise assumes that you have properly installed and configured Windows Server 2003, Enterprise Edition and joined it to the sps.local domain.

  1. Select Start Manage Your Server to open the Manage Your Server page.

  2. On the Manage Your Server page, click "Add or remove a role" to run the Configure Your Server wizard.

  3. In the Configure Your Server wizard, click Next.

  4. In the Server Role list, select Terminal Server.

  5. Click Next.

  6. View the summary screen and click Next.

  7. After the installation is complete and the server reboots, click Finish.

Installing the Web Client

In order to access Terminal Services through the portal, you will use the web-based client control that ships with Windows 2003. Web-based access to Terminal Services is not configured by default. It must be installed separately along with Internet Information Server (IIS).

  1. Select Start Control Panel Add or Remove Programs.

  2. In the Add or Remove Programs dialog, click Add/Remove Windows Components .

  3. In the Windows Components wizard, click Application Server and then the Details button.

  4. In the Application Server dialog, click Internet Information Services and then the Details button.

  5. In the Internet Information Services dialog, click World Wide Web Service and then the Details button.

  6. In the World Wide Web Service dialog, check Remote Desktop Web Connection.

  7. Click OK.

  8. In the Internet Information Service dialog, click OK.

  9. In the Application Server dialog, check ASP.NET and then click OK.

  10. In the Windows Components wizard, click Next.

  11. When installation is complete, click Finish.

Testing the Web Client

Once you have installed the web-based Terminal Services client, you can test it from any browser. The web client installation comes with a default web page that can be used immediately to access a terminal server. The actual functionality is provided by an ActiveX control that is automatically downloaded when the page is accessed.

  1. Log in to SPSClient .

  2. Open an instance of Internet Explorer.

  3. Navigate the browser to http://ts2k3/tsweb/default.htm to view the Remote Desktop Web Connection page.

  4. In the Remote Desktop Web Connection page, type TS2K3 into the Server box.

  5. In the Size drop-down box select 800 by 600.

  6. Click Connect.

  7. Use your administrator credentials to log in to TS2K3 .

  8. Log off of TS2K3 .

  9. Close Internet Explorer.

Configuring Terminal Services

Once you have verified that the web client is working correctly, you will need to configure Terminal Services for this exercise. By default, Terminal Services always logs remote users into a desktop session. Additionally, the default configuration always requires the user to enter a user name and password. In this example, you will configure Terminal Services to provide access to a single application through a common set of credentials. This will allow you to provide access to the application through the portal.

  1. Select Start Administrative Tools Terminal Services Configuration.

  2. In the configuration dialog, open the Connections folder.

  3. Right-click the RDP-Tcp connection and select Properties from the popup menu.

  4. On the Environment tab, check the "Override settings from user profile and Remote Desktop Connection or Terminal Services client" box.

  5. In the "Program path and file name" text box, type c:\windows\notepad.exe to make Notepad the application that runs when a user connects to Terminal Services.

  6. On the Logon Settings tab, select the "Always use the following logon information" option.

  7. Enter a user name and password with permission to log on to the server and run the application.

  8. Click OK.

Note

Configuring Terminal Services to run a single application is best done by creating a policy in Active Directory. You are configuring the server directly to simplify the exercise. Consult the help documentation for Terminal Services for best practices.

Creating the New Web Page

Although you can use the default web page that installs with the remote desktop connection components, typically you will want to modify the page. In this exercise, you will create your own simple ASP.NET page that accepts query string parameters as input. When the parameters are received, you will use ASP.NET to write a client-side script that will use the Terminal Services ActiveX control.

  1. Log on to SPSPortal as the domain administrator.

  2. Start Visual Studio .NET.

  3. Select File New Project from the menu.

  4. In the Add New Project dialog, open the Visual Basic Projects folder.

  5. Select to create a new ASP.NET web application.

  6. In the Location text box, type http://ts2k3/SPSTSWeb .

    Note

    Ensure that the wwwroot directory is shared on TS2K3 or Visual Studio will not be able to create the project.

  7. Click OK.

  8. In the Solution Explorer, rename WebForm1.aspx to Default.aspx .

  9. In the Solution Explorer, open the code view for the page Default.aspx .

  10. Modify the Page_Load event to generate the client-side HTML and script as shown in Listing 7-11.

    Listing 7-11: Creating the HTML and Script

    start example
     Private Sub Page_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load  With Response   .Write(vbCrLf)   .Write("<script language=""VBScript"">" + vbCrLf)   .Write("<!" + vbCrLf)   .Write("Sub StateChange" + vbCrLf)   .Write("  set RDP = Document.getElementById(""MsRdpClient"")" + vbCrLf)   .Write("  If RDP.ReadyState = 4 Then" + vbCrLf)   .Write("    RDP.Server = """ + Request.QueryString("Server") + """" + vbCrLf)   .Write("    RDP.FullScreen = " + Request.QueryString("FullScreen") + vbCrLf)   .Write("    RDP.DesktopWidth = """ + Request.QueryString("DesktopWidth") _ + """" + vbCrLf)   .Write("    RDP.DesktopHeight = """ + Request.QueryString("DesktopHeight") _ + """" + vbCrLf)   .Write("    RDP.AdvancedSettings2.RedirectDrives = " _  + Request.QueryString("RedirectDrives") + vbCrLf)   .Write("    RDP.AdvancedSettings2.RedirectPrinters = " _ + Request.QueryString("RedirectPrinters") + vbCrLf)   .Write("    RDP.FullScreenTitle = """ + Request.QueryString("Title") + _ """" + vbCrLf)   .Write("    RDP.Connect" + vbCrLf)   .Write(" End If" + vbCrLf)   .Write("End Sub" + vbCrLf)   .Write(">" + vbCrLf)   .Write("</script>" + vbCrLf)   .Write(vbCrLf)   .Write("<OBJECT ID=""MsRdpClient"" Language=""VBScript""" + vbCrLf)   .Write("CLASSID=""CLSID:7584c670-2274-4efb-b00b-d6aaba6d3850""" + vbCrLf)   .Write("CODEBASE=""msrdp.cab#version=5,2,3790,0""" + vbCrLf)   .Write("OnReadyStateChange=""StateChange""" + vbCrLf)   .Write("WIDTH=""" + Request.QueryString("DisplayWidth") + """" + vbCrLf)   .Write("HEIGHT=""" + Request.QueryString("DisplayHeight") + """" + vbCrLf)   .Write("</OBJECT>" + vbCrLf)  End With End Sub 
    end example
     
  11. Once the web page is correctly modified, select Build Build SPSTSWeb from the menu.

Creating the Web Part

The ASP.NET web application created in the previous steps could be called directly from any browser to access Terminal Services using the web client. However, you will want to integrate the functionality into SPS by creating a web part that will dynamically build a hyperlink to call the page. The hyperlink will be created based on several properties of the web part. In this way, you will be able to configure access to Terminal Services using the properties of the web part.

Because you should be reasonably adept at creating the basic framework for a web part, I will not repeat the detailed instructions here. Simply open Visual Studio and create a new web part project using VB.NET. Name the new project SPSTerminal and name the class Client .

Defining the Properties

Your web part is limited to creating a simple hyperlink based on the properties necessary to access the Terminal Services web client. Although there are several properties, each of them corresponds to a value required by the Terminal Services web client. Add code to your web part to define the properties in Table 7-5.

Table 7-5.Web: Part Properties

NAME

TYPE

DEFAULT VALUE

DESCRIPTION

URL

String

The URL where the web client ASP.NET page is located

Server

String

The name of the Terminal Services server

FullScreen

Boolean

False

Determines if the Terminal Services session runs in full screen mode

DisplayWidth

String

100%

Specifies the relative width of the session viewer

DisplayHeight

String

100%

Specifies the relative height of the session viewer

DesktopWidth

Integer

800

Specifies the width of the Terminal Services desktop

DesktopHeight

Integer

600

Specifies the height of the Terminal Services desktop

RedirectDrives

Boolean

False

Determines if the client drives are mapped to the Terminal Services session

RedirectPrinters

Boolean

True

Determines if the client printers are mapped to the Terminal Services session

Rendering the Web Part

Because you are simply creating a hyperlink as the sole interface element of the web part, no child controls are required. All you have to do is create the hyperlink in the RenderWebPart method. Add the code in Listing 7-12 to create the hyperlink for the web part.

Listing 7-12: Creating the Hyperlink
start example
 Protected Overrides Sub RenderWebPart(_ ByVal output As System.Web.UI.HtmlTextWriter)     With output         Dim strConnectURL As String = ""         strConnectURL += URL         strConnectURL += "?Server=" + Server         strConnectURL += "&FullScreen=" + FullScreen.ToString         strConnectURL += "&DeskTopWidth=" + DesktopWidth.ToString         strConnectURL += "&DeskTopHeight=" + DesktopHeight.ToString         strConnectURL += "&DisplayWidth=" + DisplayWidth         strConnectURL += "&DisplayHeight=" + DisplayHeight         strConnectURL += "&RedirectDrives=" + RedirectDrives.ToString         strConnectURL += "&RedirectPrinters=" + RedirectPrinters.ToString         strConnectURL += "&Title=" + Title         .Write("<a href=""" + strConnectURL + """ Target=""_blank"">" & _           "Connect to " + Server + "</a><br>" + vbCrLf)     End With End Sub 
end example
 

Deploying the Web Part

Deploying the Terminal Services web part is no different than deploying any basic web part. No special permissions are required for the part to run, so you should modify the web part description file appropriately, generate a strong name, build the part, and mark it as safe. You have already performed these steps several times in various exercises, so I will not repeat the steps here.

Using the Web Part

Once the web part is properly compiled, you should be able to add it to a site in SPS. The web part itself is an unassuming hyperlink; however, it should access the Terminal Services client when properly configured. Set the properties for the web part as listed in Table 7-6. Then click the hyperlink and verify that Notepad starts in a Terminal Services session.

Table 7-6: Property Settings for the Web Part

NAME

VALUE

URL

http://ts2k3/SPSTSWeb/Default.aspx

Server

ts2k3

FullScreen

False

DisplayWidth

100%

DisplayHeight

100%

DesktopWidth

800

DesktopHeight

600

RedirectDrives

False

RedirectPrinters

True

Note

The Remote Desktop ActiveX control must be installed on the client accessing Terminal Services.




Microsoft SharePoint[c] Building Office 2003 Solutions
Microsoft SharePoint[c] Building Office 2003 Solutions
ISBN: 1590593383
EAN: N/A
Year: 2006
Pages: 92

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net