HOWTO: Automatically Login to OWA 2007 using HTML + JavaScript

First thing first, you should understand that this is NOT SUPPORTED & NOT RECOMMENDED solution by Microsoft.

This is just a proof of concept that OWA 2007 can be auto login, if you know the username & password of target account.

The approach is simple and took me little reverse engineering or OWA’s login page. Owa login page being HTML does a form submit and post the username/password along with few hidden variables and upon receiving those parameters owaauth.dll generate a cookie, assign it to the session and redirect you to your mailbox. How easy, you may say.. but how you can submit those parameters programmatically.

This is how its done…

function LoginToOWA (server,domain,username,password) {
  var url = "https://" + server + "/exchweb/bin/auth/owaauth.dll";
  var p = {destination:'https://' + server + '/exchange',flags:'0',forcedownlevel:'0',trusted:'0',isutf8:'1',username:domain + '\\' + username,password:password};
  var myForm = document.createElement("form");
  myForm.method="post" ;
  myForm.action = url ;

  for (var k in p) {
    var myInput = document.createElement("input") ;
    myInput.setAttribute("name", k) ;
    myInput.setAttribute("value", p[k]);
    myForm.appendChild(myInput) ;
  document.body.appendChild(myForm) ;
  myForm.submit() ;
  document.body.removeChild(myForm) ;

<body onload="javascript:LoginToOWA('','domain','username','password');">
<h3>Please wait while redirecting to OWA...</h3>
 Happy Coding!!! 
Share this post :