Cas sso combined with ASP

Source: Internet
Author: User
Tags servervariables
Dim casserver
Casserver = "localhost: 8443/CAS"

'Destare additional variables used for redirect
Dim protocol, originatingurl, casenetworkid

'Termine the protocol for the originitating page
If request. servervariables ("HTTPS") = "off" then
Protocol = "HTTP"
Else
Protocol = "HTTPS"
End if

'Construct the originatingurl Variable Based on servervariables
Originatingurl = protocol & ": // localhost" & request. servervariables ("url ")

'Check to see if the 'ticket' variable was passed via the query string
If request. querystring ("ticket") = "" then
'If no, then redirect to cas

Response. Redirect ("https: //" & casserver & "/login? Service = "& originatingurl +" & url = "& originatingurl)
Else
Dim objsvrhttp, ticket, casresponse, casresponsearray

Ticket = request. querystring ("ticket ")

Set objsvrhttp = server. Createobject ("msxml2.serverxmlhttp. 5.0 ")
Objsvrhttp. Open "get", "https: //" & casserver & "/validate? Ticket = "+ ticket +" & service = "& originatingurl, false
'Response. Write "https: //" & casserver & "/validate? Ticket = "+ ticket +" & service = "& originatingurl
Objsvrhttp. setoption (2) = 13056

Objsvrhttp. Send
Casresponse = objsvrhttp. responsetext
Casresponsearray = Split (casresponse, CHR (10),-1, 1)

If casresponsearray (0) = "no" then
Response. Redirect ("https: //" & casserver & "/login? Service = "& originatingurl)
Else
Casenetworkid = casresponsearray (1)
If casenetworkid = "masterqi" then
'Read the database and set the user session Value
Session ("netid") = "masterqi"
Session ("userid") = "592"
Session ("username") = "masterqi"
Session ("color") = "masterqi3"
Session ("corpid") = "116"
Session ("deptid") = "144"
Session ("deptname") = "Technology Development Department"
Session ("password") = "0000"
Session ("corpidlist") = "116,144,145,146,157,158,159"
Session ("screenwidth") = 1024
End if
End if

End if

========================================================== ======================================

If an error is reported in the send method in your current debugging, use serverxmlhttp.4.0 or serverxmlhttp.5.0.

Add objsvrhttp. setoption (2) = 13056 to solve the problem.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.