Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Convert Jscript to Vbscript

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,2792
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Convert Jscript to Vbscript
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Convert Jscript to Vbscript - 4/25/2005 1:17:26 AM   
  coolkille

 

Posts: 1
Score: 0
Joined: 4/25/2005
From:
Status: offline
can some one help me convert this code to Vbscript.
Regards Micke

<%@ Language=JScript %>
<%
// Sample ASP code that uses CAS
// 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://secure.its.yale.edu/cas/servlet/";
// 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 CAS_Server = "https://secure.kau.se:443/";
var MyServer = "http://se-sol1-bl01-04/Approveit/";

// 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+"gui/inv_gui_login_karlstad1.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+"serviceValidate?service="+MyServer+"&ticket="+"ticket";
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
}
}
%>
 
 
Post #: 1
 
 Re: Convert Jscript to Vbscript - 5/7/2005 5:35:46 AM   
  JohnnyGeek

 

Posts: 1
Score: 0
Joined: 5/6/2005
From:
Status: offline
I feel your pain...

I have connected with many a CAS system, and this is the exact same script I was given to use - and it drove me nuts.

Couple of things -

First, I noticed your script uses "serviceValidate?service=". That may not be wrong - just thought I'd mention that every one I've ever connected to, it was "validate?service=". Check with the UNIX admin wherever you're trying to connect if you have issues.

Second, I noticed your "MyServer" service is not secure (https). I've had nothing but issues trying to connect without being secured. You'll notice there is a line in my script directly under the Set Server.CreateObject line, defining a "setOption 2" variable for the "MSXML2.ServerXMLHTTP.4.0" object. This commented line (when uncommented) tells the server to ignore any SSL related errors.

Good luck.


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%

Dim CAS_Server, MyServer, uid, ticket

CAS_Server = "https://secure.kau.se:443/"
MyServer = "http://se-sol1-bl01-04/Approveit/"
MyLogon = "gui/inv_gui_login_karlstad1.asp"
uid = Session.Contents("Netid")
ticket = Request.QueryString("ticket")

'See if already logged on
If uid = "" Then

'Check for ticket returned by CAS redirect
If ticket = "" Then 'There is no ticket

'No session, no ticket, Redirect to CAS Logon page
Response.Redirect(CAS_Server & "login?service=" & MyServer & MyLogon)

Else 'There is a ticket, check for validity

'Back from CAS, validate ticket and get userid
Dim http, url, resp, greeting
url = CAS_Server & "serviceValidate?service=" & MyServer & "&ticket=" & ticket
Set http = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
'http.setOption 2, SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
http.open "GET", url, false
http.send

resp = Split(http.responseText,vbLf) 'Lines become array members

Set http = Nothing 'Don't leave the object open - you're done with it.

If resp(0) = "yes" 'Logon succesful

greeting = resp(1) 'get userid for message
Session.Contents("Netid") = resp(1) 'Save for subsiquent calls

Else 'Logon unsuccessful - Optional

Response.write("Logon Failed") 'Optional

End If 'End if resp(0) = yes

End If 'End if check for ticket

End If 'End if check for already logged on

%>

(in reply to coolkille)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Convert Jscript to Vbscript Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts