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 :

Comments (11)

  1. Vermyndax says:

    This is great, but I’m looking for a way to implement this very same thing in

    I’d like to have two textboxes that capture input and fire this javascript (or its equivalent) to post the login to the OWA page.  Any advice?  I’ve looked high and low to integrate the javascript above into a aspx page with a codebehind but I’ve had no luck.

  2. Raju says:

    Hi, I'm able to use mentioned script.

    Is it possible the send emails with same link.

    appreciated if replied quickly

  3. hi Is it possible send the emails from above code.

    If yes how could

  4. Younis Alomoush says:


    I tried your solution, however it is still redirecting me again to the log in page.

    any ideas?

  5. Thanks, this code works fine for me.

    For OWA 2010 replace the dll path:


    with this:



    OWA 2010 support mailbox selection from the URL, for example:


  6. Ravi says:

    I cant able to log in using this method any other options are available.

    i am redirecting to the logon.aspx page when page load completes

  7. Ravi Panjabi says:

    i cant able to redirect after login using this code. can u help me

    i wants to login directly to OWA without user authentication on user side.

  8. Shaun says:


    Thanks for the code, seems this is the only source.

    I am using OWA 2010 it works with the minor tweak "Tiziano Sartori" suggested.

    But when i change to IE8 from IE6, it does not work anymore.

    Any suggestions ?

  9. Hoa says:

    it does not work if password includes single quote or double quote, is there anyway to fix???

  10. Mike T says:

    You, sir, have made my week! Awesome, awesome, awesome.

Skip to main content