• 【原创】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>
  • 相关阅读:
    FastMM、FastCode、FastMove的使用(图文并茂)
    12种JavaScript MVC框架之比较
    十款最佳Node.js MVC框架
    Couchbase 服务器
    C#程序员阅读的书籍
    ORM的实现
    Linux内核策略介绍
    ASP.NET MVC + EF 利用存储过程读取大数据
    面向.Net程序员的dump分析
    动态加载与插件化
  • 原文地址:https://www.cnblogs.com/xiongnanbin/p/542843089ac49ad60dc61e5e360d204f.html
Copyright © 2020-2023  润新知