Logon.csp

To download the CSP files from this tutorial, click TutorialSamples_vb.zip. For more information about using the samples, see Code examples.


<%@ Language=VBScript %>

<HTML>

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

<BODY>

<%


    Dim UserID, Password, APS, Aut

    

    'Retrieve the user information from the form

    'on the previous page.

    APS = Request.querystring("APS")

    UserID = Request.form("UserID")

    Password= Request.form("Password")

    

    'Authentication type.

    Aut = Request.form("Aut")


Response.Expires = 0

    

On Error Resume Next

    Dim SessionManager


    'Create an Enterprise SessionManager.

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

    

    If Err.Number <> 0 then

        Response.Write "Couldn't create SessionManager"

        'Handle error here.

    Else

        Dim Sess

        'Log the user onto Crystal Enterprise.

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

        

        'Check to see if logon failed.

        If Err.Number <> 0 then


                

            'If the logon failed show a message box with an error description.

            Response.Write "<SCRIPT language=""javascript""> " & _

            " alert (""Sorry - you could not be logged on to " & _

            "this server. Ensure that your user name and " & _

            "password, as well as the APS name are correct. " & _

            """);</SCRIPT>"

            

            'Redirect the user back to the logon page.

            'Response.Redirect "LogonForm.csp"

            Response.Write "<META HTTP-EQUIV='refresh' CONTENT='0;URL=LogonForm.csp'>"

        Else

            Dim IStore

            Dim LogonTokenMgr

            

            'Create the InfoStore object.

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


            'Store the InfoStore object in the session.

            Session("IStore") = IStore


            'Retrieve the LogonTokenManager.

            Set LogonTokenMgr = Sess.LogonTokenMgr

            

            'Session("IStore") = Sess.LogonTokenMgr

            

            'Retrieve a Logon Token and store it in the user's cookie file for later use.

            Response.Cookies("LogonToken") = LogonTokenMgr.CreateLogonTokenEx("", 60, 100)


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

            Response.Redirect "home.csp?FolderID=0"        

        End If

    End If

%>

</BODY>

</HTML>






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