m_collard m_collard - 4 months ago 11
HTML Question

How do you automatically Login to OWA 2013 using HTML + JavaScript

We used to use Exchange 2007 and the HTML + JavaScript below to log into OWA 2007 automatically.

But we've now upgraded to Exchange 2013 and the script no longer works. It displays 404 - File or directory not found.
I've asked our Infrastructure department if the owaauth.dll file is still in the same location, and they have told me it's moved to:

https://" + server + "/exchweb/auth/owaauth.dll


I changed the script to use the new path, but I still get the
404 - File or directory not found
error.

My question is what do I need to change in the script to make it work with Exchange 2013?

Here are the Exchange 2007 script details

HOWTO: Automatically Login to OWA 2007 using HTML + JavaScript

<script>
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) ;
}
</script>

<body onload="javascript:LoginToOWA('owa.exchange.com','domain','username','password');">
<h3>Please wait while redirecting to OWA...</h3>
</Body>

Answer

Worked it out. Here's the new script that works with OWA 2013:

<script>
function LoginToOWA (server,domain,username,password,useremailaddress) {

  var url = "https://" + server + "/owa/" + useremailaddress + "/auth/owaauth.dll"; 
  var p = {destination:'https://' + server + '/owa/#path=/mail',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) ;
}
</script>

<body onload="javascript:LoginToOWA('owa.exchange.com','domain','username','password','user@emailaddress.com');">
<h3>Please wait while redirecting to OWA...</h3>
</Body>