Skip to content

关于Exchange2007基于表单验证的处理

最近做一个系统,前端要加入Exchange OWA的登录,很是恼火,用尽了各种办法都没有解决,我觉得会不会是服务器端设置的问题呢?

我看网上一般的做法是这样的:

javascript
function DirectLogin (vstrServer, vstrDomain, vstrUsername, vstrPassword) {

      //var url = "https://" + server + "/exchweb/bin/auth/owaauth.dll";
      var strUrl = "https://" + vstrServer + "/exchweb/bin/auth/owaauth.dll";
      var strExchange = {destination:'https://' + vstrServer +
         '/exchange',flags:'0',forcedownlevel:'0',
         trusted:'0',isutf8:'1',username:vstrDomain +
         '\\' + vstrUsername,password:vstrPassword};

      var myForm = document.createElement("form");
      myForm.method="post" ;
      myForm.action = url ;

      for (var varElement in strExchange) {

        var myInput = document.createElement("input") ;
        myInput.setAttribute("name", varElement) ;
        myInput.setAttribute("value", strExchange[varElement]);
        myForm.appendChild(myInput) ;
      }

      document.body.appendChild(myForm) ;
      myForm.submit() ;
      document.body.removeChild(myForm) ;
}

我在项目里是这样做的:

html
<div class="topbar fl">
	<span class="fl"><script>document.write( customDateString(new Date()) );</script></span>
	<div class="login fr">
		<form action="https://aaaa/auth/owaauth.dll" method="POST" name="logonForm" id="mailLogin" target="_self">
		<input type="hidden" value="https://mail.caac.gov.cn/exchange" name="destination" />
		<input type="hidden" value="0" name="flags" />
		<input type="hidden" value="0" name="forcedownlevel" />
		<input type="hidden" value="0" name="trusted" />
		<input type="hidden" value="1" name="isutf8"/ />
		<a href="http://www.abc.com/abc/aaa.aspx" target="_blank">邮箱</a>
		<label>用户名:</label>
		<input type="text" class="txt fl" name="username" id="username" />
		<label>密码:</label>
		<input type="password" class="txt fl" name="password" id="password" />
		<input type="submit" class="btn fl" value="登录" />
		</form>
	</div>
</div>
<script type="text/javascript">
if(jQuery){
	$(function(){
		var form = $("form#mailLogin");
		form.submit(function(){
			var button = form.find("input.btn");
			button.attr("disabled","disabled");
			if(fucCheckNull(form.find("input#username").val(),"请输入用户名!")==false){
				button.removeAttr("disabled");
				return false;
			}
			else if(fucCheckNull(form.find("input#password").val(),"请输入密码!")==false){
				button.removeAttr("disabled");
				return false;
			}

		});
	});
}
</script>