Data4Strategy

——合抱之木,生于毫末;九层之台,起于累土

【原创】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>

 

posted @ 2013-09-21 08:57  John.Xiong  阅读(566)  评论(0编辑  收藏  举报