<%@ Language=JScript %> <% // Sample ASP code that uses CAS // By Howard Gilbert // If you logon, it says "Hello " followed by your userid // For the Web server to talk to the CAS server, this code depends on the // Microsoft ServerXMLHTTP control provided with MSXML. If the MS XML // parser is not already installed on the IIS host machine, // download version 3.0 SP1 or better from http://www.microsoft.com/xml // Insert name of CAS Server at your location var CAS_Server = "https://netid-test.tamu.edu/cas"; // Insert public name of IIS Server hosting this script // Note: Request.ServerVariables("SERVER_NAME") or anything based on // the HTTP "Host" header should NOT be used; this header is supplied by // the client and isn't trusted. (--SB) var MyServer = "http://appel.yu.yale.edu/"; greeting = "World"; // In case I fail // See if already logged on var uid = Session.Contents("Netid"); if (!uid){ // Check for ticket returned by CAS redirect var ticket = Request.QueryString.Item("ticket").Item; if (!ticket) { // No session, no ticket, Redirect to CAS Logon page var url = CAS_Server+"login?"+ "service="+MyServer+"HelloCas/default.asp" Response.Redirect(url); Response.End; } else { // Back from CAS, validate ticket and get userid var http = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0"); var url =CAS_Server+"validate?ticket="+ticket+"&"+ "service="+MyServer+"HelloCas/default.asp"; http.open("GET",url,false); // HTTP transaction to CAS server http.send(); var resp=http.responseText.split('\n'); // Lines become array members if (resp[0]=="yes") // Logon successful greeting=resp[1]; // get userid for message Session.Contents("Netid")=resp[1]; // Save for subsequent calls } } %> CAS ASP Example application

Hello <%=greeting%>