Single Sign-on with Cookies
This article provides instructions for adding single sign-on capabilities when external authentication is not an option. This can be beneficial if PIN is the selected authentication method.
This customization was designed for the r11.x releases, and is untested in older releases.
Step 1. Edit the login.htmpl form
In the login.htmpl file, the following additions are needed. Click here to download an example login.htmpl file containing all the code provided below.
Add the following scripts near the top of the BODY where the other javascripts reside: <source lang="javascript">function createCookie(name,value,days){
if(value != ""){
n_value=encodeURIComponent(value);
}else{
n_value = "";
}
if(days){
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+n_value+expires+"; path=/";
}
function readCookie(name){
var nameEQ = name + "=";
var b = document.cookie.split(';');
for(var i=0;i < b.length;i++){
var c = b[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0){
d = c.substring(nameEQ.length,c.length);
if(name == c_name1) g_id = d;
if(name == c_name2) g_pin = d;
}
}
}
var c_name1 = "CA_USERNAME", c_name2 = "CA_PIN"; var g_id = "", g_pin = ""; var l_flag = 0; var url_string = String(document.location); var url_array = url_string.split('?'); if(url_array[1]){
f = url_array[1];
// if(f.indexOf("OP=LOGOUT") != -1) window.close(); //Closes window on LOGOUT
}else{
readCookie(c_name1); readCookie(c_name2); if(g_id != "" && g_pin != "") l_flag = 1;
} </source>
Replace the USERNAME and PIN input fields in the middle of the form with the two provided below: <source lang="javascript"><input type="text" id="USERNAME" name="USERNAME" size=20 onFocus="this.className='focusField';" onBlur="this.className=;if(this.value != ){createCookie('CA_USERNAME',this.value,1)};"> //ADDED createCookie</source> <source lang="javascript"><input type="password" id="PIN" name="PIN" size=20 onFocus="this.className='focusField';" onBlur="this.className=;if(this.value != ){createCookie('CA_PIN',this.value,1)};"> //ADDED createCookie</source>
Add the following near the bottom of the page: <source lang="javascript"><PDM_IF "$prop.WSPHOST" == "" && "$LoginErrMsg" == ""> if(l_flag == 1){
//If the l_flag is set to 1, USERNAME and PIN is set and a pdm_submit is initiated for an automatic logon
document.forms["login"].SID.value = "0";
document.getElementById("USERNAME").value = g_id;
document.getElementById("PIN").value = g_pin;
pdm_submit('login',);
} </PDM_IF></source>
For r11.x releases it is recommended that you edit your pages via the Web Screen Painter. For older releases you must edit the files directly.
Step 2. Publish the Schema changes
Follow these steps for publishing the schema changes:
- Save your Schema changes
- Stop the Service Desk service
- Run pdm_publish from a command line
- Start the Service Desk service
To discuss or ask questions about this article, select the discussion tab above.