CAS SSO结合ASP搞定
2006-11-14 10:24
深圳·公司 上次因为集成的ASP只能先登录ASPX后才能进入ASP这是老大不想要的,因此通过两天的茶饭不思,昼 思夜想终于有了可喜的结果。当然,现在只是纯粹的学习和测试,并没有用到项目中去。 下面将代码贴出来:setoption ======================================================================== Dim casServer casServer = "localhost:8443/cas" 'Declare additional variables used for redirect Dim protocol, originatingURL, caseNetworkID 'Determine 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("" & 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", "" & casServer & "/validate?ticket="+ ticket +"&service=" & originatingURL, false 'Response.Write "" & casServer & "/validate?ticket="+ ticket +"&service=" & originatingURL objSvrHTTP.setOption(2) = 13056 objSvrHTTP.send casResponse = sponseText casResponseArray = Split(casResponse, Chr(10), -1, 1) if casResponseArray(0) = "no" then Response.Redirect("" & casServer & "/login?service=" & originatingURL) else caseNetworkID = casResponseArray(1) if caseNetworkID="masterQi" then '读数据库,进行用户session设值 Session("netId")="masterQi" Session("userId")="592" Session("username")="masterQi" Session("color")="masterQi3" Session("corpId")="116" Session("deptId")="144" Session("deptName")="技术开发部" Session("PassWord")="0000" Session("corpIdList")="116,144,145,146,157,158,159" Session("Screenwidth")=1024 end if end if end if ======================================================================== 如果,你现在的调试中在send方法那里报错的话, 请用ServerXMLHTTP.4.0或ServerXMLHTTP.5.0 并加上objSvrHTTP.setOption(2) = 13056 ,即可解决 |
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论