Home > Domino Tips > Developer > Domino SSO Timer: Updated version
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Domino SSO Timer: Updated version


Dennis Potts
05.19.2005
Rating: --- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


This agent and JavaScript code will automatically create a pop-under window that waits x number of seconds before your SSO expiration time occurs. The agent has four constants and one variable for configuring the agent.

The agent constants are:
maxWait% -- An integer constant that must be set to the number of minutes to wait before a pop-up appears for the user to log in again. The value should be less than the SSO expiration time.
msgText$ -- A string constant that defines the text information that will appear in the body of the pop-under window.
titleText$ -- The string constant used to define the title of the browser's pop-under window.
fileName$ -- The string constant that defines the NSF file which contains the agent. (Include relative path information in the NSF name. For example, utilsMyNsfFile.nsf.)
popupText$ -- The string constant that defines the text which will appear in the alert message when the SSO expiration time -- maxWait% time elapses.
There is also a string variable called urlRedirect$. It contains the value "SSOTimer" as the name of the agent. Replace "SSOTimer" to the same name you gave to your agent that contains the code.

The agent should have the following settings:
When should this agent run? = Manually from agent list
Which document(s) should it act on? = Run once (@Commands may be used)

The agent will detect if it was called from a parent window. If so, focus will be returned to the parent window after the user responds to the alert message and logs onto the server again.

To call the agent and create the pop-under window, you will have to call the agent using some JavaScript code. I have Web applications that present the user with a navigator and an embedded view. Of course, the embedded view is contained in a form. That is where I added the onLoad JavaScript code.

The JavaScript code will set a cookie that has a life span of the Web session. If the cookie is not set, it assumes that the pop-under window needs to be loaded. You are not limited to using the JavaScript code in the onLoad event. Use it anywhere that makes sense as your known starting point into your Web application.

In summary, the process works as follows:
1. User logs into Web application and triggers the agent to run in a pop-under window.
2. The pop-under window waits for the specified period of time and then alerts the user with a user defined message.
3. User logs in with user name and password again (refreshingSSO expiration time).
4. Focus is returned to the parent window.

Three changes have been made to the updated version of this tip:
1. If a pop-under window remains after the parent is closed (an orphan), it will be closed before the new parent window creates the new pop-under window. This will ensure the child has a handle on the current parent.
2. The pop-under window will not attempt to show an alert box after the designated wait time if the parent is gone.
3. The login screen will resize to full-screen when it becomes visible and comes into focus.

Code

LotusScript Code: 

Sub Initialize
 Const maxWait% = 115'Change to 
the desired number of minutes to wait
 Const msgText$ = "Single Sign-On Timer - 
Waits five minutes before the web session 
times out and pop-ups up to ask user to 
sign in again to prevent losing any information."
 Const titleText$ = "Domino Password Timer"
 Const fileName$ = "YourNotesDb.nsf" 
 Const popupText$ = "Your password will 
expire in five minutes.  Press OK to enter your 
user name and password again.  
This will prevent losing any information."
 Dim urlRedirect As String
 
 urlRedirect$ = fileName$  + "/?logout&redirectTo=" 
+ fileName$ + "/SSOTimer?openagent"
 
 Print "<head>"
 Print |<META HTTP-EQUIV='Refresh' CONTENT='| 
+ Trim(Cstr( maxWait% * 60 ) ) + |; URL=| +
 urlRedirect$ + |'></head>|
 Print "<TITLE>" + titleText$ + "</TITLE>" 
 Print |<BODY TEXT="000000" BGCOLOR="FFFFFF"
 onUnload="top.window.moveTo(0,0);
 if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}|
 
 Print "else if (document.layers||document.getElementById) {"
 Print "if (top.window.outerHeight<
screen.availHeight||top.window.outerWidth<screen.availWidth){"
 Print |top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
 
top.window.focus();
var curDate = new Date();

if( ! opener.window.closed ) {alert( curDate + 
": | + popupText$ + |");}|
 
 
 Print |" onLoad="top.window.moveTo(0,0);
 if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}|
 
 Print "else if (document.layers||document.getElementById) {"
 Print "if (top.window.outerHeight<
screen.availHeight||top.window.outerWidth<screen.availWidth){"
 Print |top.window.outerHeight = 0;
top.window.outerWidth = 300;
}
}
 
 if ( opener ) {
 opener.window.focus();
}">| _
+ msgText$ + "</body>"
 
End Sub



JavaScript Code:


/*===============================*/

function getPath() {
var curURL = "" + window.location;
var pos = curURL.indexOf(".nsf");
 //find the position var path = "";

if ( pos != -1 ) {
 path =  curURL.substring(0, pos) + ".nsf"; } else {
 var URLInfo = curURL.split( "/" );
 path = URLInfo[0] + "//" + URLInfo[2] + "/" + 
URLInfo[3];
}

return path;
}

/*===============================*/

function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/*===============================*/

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}


/*===============================*/

if ( getCookie( "ssoTimer" ) == null ) {
 setCookie( "ssoTimer", "Y" );
 var agentName = "SSOTimer/?openagent";        
 var dbName = getPath();
 window.open('','ssotimer').close(); 
//Close the child window in case it was
 orphaned and points to a parent that does not exist 
 ssoWin = window.open(dbName + "/" + agentName , 
"ssotimer", "width=700,height=450,status=no, 
resizeable=yes, scrollbars=yes, menubar=no"); 
 ssoWin.blur();
 window.focus();
}

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Dennis Potts. Please let others know how useful it is via the rating scale at the end of the tip. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Agent
LotusScript agent moves new mail to folder
Quickly scan all databases on a Lotus Domino server
Run or restart Notes/Domino agents via text messages
Approve Lotus Notes documents using a BlackBerry mobile device
LotusScript agent indexes Lotus Notes/Domino databases
Open documents in Lotus Notes from the Web without a UNID
Fix and update Lotus Notes documents with limited access
Verify scheduled agent status with Domino Extensible Language (DXL)
How to export data from a Lotus Notes database to a CSV file
Enable or disable scheduled agents without opening the Lotus Notes database design

JavaScript
Displaying a custom icon view column in Xpages
Trap JavaScript runtime errors in Domino Web apps
JavaScript workaround fixes Lotus Notes 8.x PostOpen event issue
Write HTML and JavaScript in Notes view rows and columns on the Web
JavaScript detects Web browser type and version in Notes/Domino 8.0.2
JavaScript creates a jump box on a Lotus Notes Web form
How to create dynamic JavaScript in Notes Domino without formulas
Trap an attachment path via the Domino file upload control field
Converting Lotus Notes views to XML documents using JavaScript
Prevent errors on iFramed pages with JavaScript

LotusScript
Eight easy steps to open and view Flash files in Lotus Notes
LotusScript agent parses ACL to Microsoft Notepad
LotusScript finds the first occurrence of a string from the right
Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
Search Microsoft Active Directory with LotusScript
Three steps to trap and handle save conflicts with LotusScript
Troubleshoot agents by displaying LotusScript variables online
LotusScript sorts lists alphabetically
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2010, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts