Tag Archives: SSO

CRM Online & Windows Azure: Improving the SSO experience

This is supposed to be one of a series of CRM Online & Windows Azure posts for which I have been building some samples.  While I really wanted to make this the second or third post, someone needed the explanation sooner, so this will be somewhat of a tease to the overall series.

Scenario:

I’ve already configured SSO across Windows Azure & CRM Online.  When I try to integrate an Azure hosted page into the CRM UI, I get the following errors:

This content cannot be displayed in a frame

To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame.

This video walks you through why you get the error and how to work around it with a better user experience.

Here’s the code for the two helper pages…

ssoinitiator.htm (CRM Web Resource)

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

    <head>

        <title></title>

        <meta http-equiv="refresh" content="5">

        <script type="text/javascript">
   1:  

   2:             function getQuerystring(key, default_) {

   3:                 if (default_ == null) default_ = "";

   4:                 key = key.replace(/[[]/, "\[").replace(/[]]/, "\]");

   5:                 var regex = new RegExp("[\?&]" + key + "=([^&#]*)");

   6:                 var qs = regex.exec(window.location.href);

   7:                 if (qs == null)

   8:                     return default_;

   9:                 else

  10:                     return qs[1];

  11:             }

  12:  

  13:             function redirectToIntendedPage() {

  14:                 window.location = decodeURIComponent(getQuerystring("data"));

  15:             }

  16:  

  17:             function bodyOnload() {

  18:                 if (document.cookie.indexOf("AZURE_SSO_COMPLETE=") != -1) {

  19:                     redirectToIntendedPage();

  20:                 } else {

  21:                     var message = document.getElementById("message");

  22:                     message.style.visibility = "visible";

  23:  

  24:                     if (document.cookie.indexOf("AZURE_SSO_INITIATED=") == -1) {

  25:                         document.cookie = "AZURE_SSO_INITIATED=true";

  26:                         window.open("https://crmazrfedtest.cloudapp.net/SSOHelper.htm");//replace with your azure hosted version

  27:                     } else {

  28:                         document.cookie = "AZURE_SSO_COMPLETE=true";

  29:                         redirectToIntendedPage();

  30:                     }

  31:                 }

  32:             }

  33:         

</script>

    </head>

    <body onload="bodyOnload() ">

        <div id="message" style="visibility:hidden">

            <h1>Initiating Single Sign On...</h1>

            <p>This page will refresh shortly.</p>

        </div>

    </body>

</html>

SSOHelper.htm (Azure hosted)

<!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>

        <title>SSO Helper</title>

        <script type="text/javascript">
   1:  

   2:             function bodyOnload() {

   3:                 window.close();

   4:             }

   5:         

</script>

        <meta http-equiv="expires" content="-1" />

        <meta http-equiv="pragma" content="no-cache" />

    </head>

    <body onload="bodyOnload()">

        <div>

            <h1>Single Sign On Complete</h1>

            <p>Please close this window.</p>

        </div>

    </body>

</html>

@devkeydet