SSOLogon.csp

<%@ Language=JavaScript %>

<%     

    // This file attempts to logon a user using the Single Sign On

    // method.  If the logon fails, then the user is directed to a

    // logon form.  Note that both the WCS and the Web Server

    // must be configured for SSO before this works.

%>

<HTML>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">

<BODY>

<!-- #include file=helper_js.csp -->

<%

function SSOLogon()

{

    var UserID, Password, APS, Aut;

    

    //Retrieve the name of the server to logon to.

    APS = Request.ServerVariables.Item("WCS_NAME_SERVER");


    //The UserID and Password are empty for SSO.

    UserID = "";

    Password= "";

    

    //NT Authentication must be used in order to use SSO.

    Aut = "secWindowsNT";


    //Don't cache the page.

    Response.Expires = 0;

    

    var SessionManager;


    //Create an Enterprise SessionManager.

    try {

        SessionManager = Server.CreateObject("CrystalEnterprise.SessionMgr");

    }

    catch(e) {

        Response.Write ("Couldn't create SessionManager");

        //Handle error here.

        return false;

    }

    

    var Sess;

    //Log the user onto Crystal Enterprise using SSO.

    //Note that the authentication type is secWindowsNT

    //and that the UserID and password are blank.

    try {

        Sess = SessionManager.Logon(UserID, Password, APS, Aut)

    }

    catch(e) {

        //If logon failed, redirect the user back to the logon page.

        Response.Redirect ("LogonForm.csp");

        return false;

    }

        

    var IStore;

    var LogonTokenMgr;

            

    //Create the InfoStore object.

    IStore = Sess.Service ("", "InfoStore");

    //Store the InfoStore object in the session.

    SetSession ("IStore",IStore);

    


    //Retrieve the LogonTokenManager.

     LogonTokenMgr = Sess.LogonTokenMgr;

                 

    //Retrieve a logon token and store it in the user's cookie file for later use.

    SetCookie("LogonToken", LogonTokenMgr.CreateLogonTokenEx("", 60, 100));


    //Redirect the user to the site's home page.    

    Response.Redirect ("Home.csp?FolderID=0");  

    return true;

}


SSOLogon();

%>

</BODY>

</HTML>






Crystal Decisions, Inc.
http://www.crystaldecisions.com
Support services:
http://support.crystaldecisions.com