【原创】SSO-Javascript模拟IE登录,不让IIS弹出登录窗口
解决方案:
用JS模拟IE用户登录,再跳转到对应的系统。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script type="text/javascript" language="javascript"> function Authen() { var Location1 = "http://bi.xxx.com"; //定义你的路径 var auth = null; if (window.XMLHttpRequest) { auth = new XMLHttpRequest(); } else if (window.ActiveXObject) { auth = new ActiveXObject("msxml2.xmlhttp"); //创建msxml2.xmlhttp对象 } //var auth = new ActiveXObject("MSXML2.XMLHTTP.6.0"); //如需要,分浏览器判断创建对象 //var auth = new ActiveXObject("MSXML2.XMLHTTP.5.0"); auth.open("get", Location1, false, "用户名", "密码"); auth.send(); switch (auth.status) { //检测auth.send以后的状态, case 200: //状态为:200代表用户名密码正确, window.location.href = Location1; //浏览器重转向 break; case 401: //状态为:401代表用户名密码不正确,身份验证错误 alert("用户无效或密码错误。"); //报错 break; default: //其它状态,如服务器无法访问 alert(auth.status); alert("对不起,服务器发生错误,请稍后再试!"); //报错 } } </script> </head> <body> <input type="button" onclick="Authen();" value="登 录"></input> </body> </html>
作者:DataStrategy
出处:https://www.cnblogs.com/xiongnanbin/
联系:1183744742@qq.com;xiongnanbin@126.com
本文版权归作者和博客园共有(转载的归原作者所有),欢迎转载,但是请在文章页面明显位置给出原文连接。如有问题或建议,请多多留言、赐教,非常感谢。