cancel
Showing results for 
Search instead for 
Did you mean: 

Logging Off Inactive User automatically in Portal 7.3

sambaran
Explorer
0 Kudos

Hi Experts,

Is there any standard configuration or solution provided in SAP EP 7.3  to log off an inactive user automatically. ?

We already have the javascript solution for this and implemented that in 7.1

https://wiki.sdn.sap.com/wiki/display/EP/EP+Snippet+-+Portal+user+idle+timeout+for+logoff+-+custom+j...

But I want to know if SAP provided any standard solution for this kind of scenario.

Any kind of information is highly appreciated.

Thanks & Regards,

Sambaran Chakraborty

Accepted Solutions (1)

Accepted Solutions (1)

former_member193577
Active Contributor
0 Kudos

Hi,

You can reduce the timeout for user sessions, so they will be logged off if inactive:

http://help.sap.com/saphelp_nw72/helpdata/en/48/88b52977323cb8e10000000a42189d/content.htm

I believe default is 600 seconds.

Regards,

Tal

sambaran
Explorer
0 Kudos

Hi,

Thanks for your reply.

But we are trying to archive a scenario where after some inactive period a pop up will occurs to warn user about session time out and then it will perform the logoff function based on user decision.

The above mentioned script successfully identified inactive session .

But the problem is that script is written for Classic framework page.

We are using AJAX Frame work page and within that (Masthead.jsp) we are not able to control/find logoff code.

I tried to use below code to call EPCM logoff method into the Masthead.jsp under <Script> . But it doesn't trigger logoff functionality.

 

EPCM.subscribeEventReliable('urn:com.sapportals:navigation',
  'AFPisLoaded',
  function _afpLoaded() {

alert('Into the EPCM event');

//Script writen here.

EPCM.getSAPTop().LSAPI.getSessionPlugin.logoff();

}
)

Can anyone please tell me what are we missing. Why the LSAPI.getSessionPlugin.logoff(); is not triggered .

Any input is highly appreciated.

Thanks & Regards,

Sambaran

fabianl
Product and Topic Expert
Product and Topic Expert
0 Kudos

hi sambaran,

do u have check this article:

http://wiki.sdn.sap.com/wiki/display/EP/EP%20Snippet%20-%20Portal%20user%20idle%20timeout%20for%20lo...

I think this is what u want!?

br,

fabian

sambaran
Explorer
0 Kudos

Thanks Fabian.

I checked that, but this is for Classic frame work page where we have HeaderiView.jsp. into the masthead file.

But we are using Ajaxframe work page  and into that there is no such file. I tried to add the same code under Masthead.jsp file . But the log off functionality is not working from there.

So I wonder in AjaxFrame work how this log off functionality handled.

Can any one guide on this.

Regards,

Sambaran Chakraborty

adren_dsouza
Participant
0 Kudos

Hi Sambaran,

I was unable to reply to your comment against the article

Anyways, I got some time to check into this... EPCM.getSAPTop().LSAPI.getSessionPlugin.logoff() must do the job in case of EP 7.3

Make sure that the AFP scripts are loaded there. I see in your previous replies that you have done that, but is that JS object null ?? In that case can you please check SAP Note 1612008

Regards,

Adren

sambaran
Explorer
0 Kudos

Hi Adren,

Yes as per sap the logoff() from LSAPI should do the job. I even checked the note and the AFP Resource iview is present into the freamework page we are using.

I couldn't find the reason why calling of  EPCM.getSAPTop().LSAPI.getSessionPlugin.logoff() from Masthead.jsp not performing the task, what are we missing?? .. !!

Anyway thanks for all your help.

I have found a workaround to perform logoff in EP 7.3 AjaxFrame work.

  NovaDialogBox.performLogout();  by using this method we are able to perform logoff task. 

You will find this method written into  AFPWidgets and AFPResource EAR file within one of the .JS file.

This method in terms call LSAPI.logoff() method and perform the expected task.

Regards,

Sambaran Chakraborty

adren_dsouza
Participant
0 Kudos

Hi Sambaran ,

Strange that EPCM.getSAPTop().LSAPI.getSessionPlugin.logoff() does not work even though its loaded !!

Anyways good to know that NovaDialogBox.performLogout() is working ..

Thanks for the update.

Cheers..

Regards,

Adren

Former Member
0 Kudos

Adren,

Did you tested in Nw 7.30 using the YUI function?

Regards,

Sethu

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Chakraborty,

Can you please share how you implemented session logout in SAP PORTAL 7.3 using AFP.

Thanks in advance,

Santosh.

sambaran
Explorer
0 Kudos

Hi Santosh,

To implement auto logout process there are already script available. You just need to use NovaDialogBox.performLogout() into the script for session logout.

Paste below code at the bottom of  masthead.jsp and let me know the result.

You might need to adjust  var timeout_h = customTimeoutHandler(40,45); as per your requirement.

Hope this will help u.

-----------------------------------------------------------------------------------------------------------------------------------------------

<script type="text/javascript">

var customTimeoutHandler = function(warn_delay, kick_delay) {

  return {

   

    debug_mode:         false,                  // Switches the display of the timer (function _displayTimer)

    timeout_wait:       1000 * 10,              // Delay for the 'setTimeout' native function

    timeout_warn_delay: 1000 * 60 * warn_delay, // Delay until the warning message

    timeout_kick_delay: 1000 * 60 * kick_delay, // Delay until the timeout message and the effective timeout

    /**

    * Initializes the custom portail timeout (called at first time)

    **/

 

    initialize: function() {

      this.updateTimer();

      setTimeout("timeout_h.checkTimeout()", this.timeout_wait);

    },

    /**

    * Updates the custom portail timeout (called whenever the user navigates in the portal)

    **/

    updateTimer: function() {

      var dt = new Date();

      writeCookie('custom_timeout', dt.getTime());

      if(this.debug_mode) {

        this._displayTimer();

      }

    },

    /**

    * Checks wether the timeout has occured or not ( repeatedly called)

    **/

     checkTimeout: function() {

      var now = new Date();

      var diff = now.getTime() - this._getTimerStart();

      if(diff > this.timeout_warn_delay) { // Action : unactive

        var date_timeout = new Date();

        date_timeout.setTime(this._getTimerStart().getTime() + this.timeout_kick_delay);

        var date_t_hours = date_timeout.getHours() + "";

        if(date_t_hours.length == 1) date_t_hours = "0" + date_t_hours;

        var date_t_min = date_timeout.getMinutes() + "";

        if(date_t_min.length == 1) date_t_min = "0" + date_t_min;

        var date_timeout_display = date_t_hours + ":" + date_t_min;

             //alert('The page was idle since last '+warn_delay+' minutes, hence the session will timeout and logoff in next 5 minutes.\n'+

         // 'Click on OK button before '+date_timeout_display+' to continue with your current session.');

      

             alert('Your session will time out in the next 5 minutes. As a security precaution, sessions expire after 45 minutes of inactivity.\n'+

                                 'Click on OK before '+date_timeout_display+' to continue your current session.');

      

        now = new Date();

        diff = now.getTime() - this._getTimerStart();

        if(diff > this.timeout_kick_delay) { // Action : kick (= time out)

           

      

            NovaDialogBox.performLogout();       

           

       

        } else {

        //  this._refreshPage();

          this.updateTimer();

          setTimeout("timeout_h.checkTimeout()", this.timeout_wait);

        }

      } else {

        setTimeout("timeout_h.checkTimeout()", this.timeout_wait);

      }

      if(this.debug_mode) {

        this._displayTimer( diff + " > " + this.timeout_kick_delay + " ? " + (diff > this.timeout_kick_delay) );

      }

    },

    /**

    *

    */

    _getTimerStart: function() {

      var timeout_start = parseInt(readCookie('custom_timeout'));

      return new Date(timeout_start);

    },

    /**

    * Displays the timer informations in the window status bar

    **/

    _displayTimer: function(message) {

      var dt = this._getTimerStart();

      var timer_start_string = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();

      if(message && message!=null && message!="") {

        window.status = timer_start_string + " - " + message;

      } else {

        window.status = timer_start_string;

      }

    },

    /**

    * Refreshes the portal page content

    **/

    _refreshPage: function() {

      try {

        frameworkSupport.refreshContentArea();

      } catch(e) {

        document.location.reload()

      }

    },

    /**

    * Subscribes to an EPCM event

    **/

    addListener: function(urn, action) {

      EPCM.subscribeEvent(urn, action, this.updateTimer);

    }

  }

}

// cookies functions

function writeCookie(name, value) {

  document.cookie = name + "=" + escape(value);

}

function readCookie(name) {

  var arg = name+'=';

  var alen = arg.length;

  var clen = document.cookie.length;

  var i=0;

  while (i < clen){

    var j = i + alen;

    if (document.cookie.substring(i, j) == arg) return getCookieVal(j);

    i=document.cookie.indexOf(' ', i) + 1;

    if (i == 0) break;

  }

  return null;

}

function getCookieVal(offset){

  var endstr = document.cookie.indexOf (';', offset);

  if (endstr == -1) endstr = document.cookie.length;

  return unescape(document.cookie.substring(offset, endstr));

}

</script>

<script type="text/javascript">

  var timeout_h = customTimeoutHandler(40,45);

  timeout_h.initialize();

  function pop() { timeout_h.updateTimer(); }

  EPCM.subscribeEvent("urn:com.sapportals:navigation", "Navigate", pop);

  //EPCM.subscribeEvent("urn:com.sapportals.portal:pageBuilder", "*", pop);

  //EPCM.subscribeEvent("urn:com.sapportals.portal:user", "*", pop);

  //EPCM.subscribeEvent("urn:com.foo.bar.myapp", "myEvent", pop);

  // Subscribe to your events here 

var closing;

  window.onload = function()

{

  closing=true;

  }

window.onunload = function() {

          if(closing) {

 

                    NovaDialogBox.performLogout();

 

          }

}

</script>

-------------------------------------------------------------------------------------------------------------------------------------------------

Regards,

Sambaran

Former Member
0 Kudos

Hi Sambaran,

We have upgraded from NW Portal 7.0 to 7.3. now here we have classic frame work page i have customised com.sap.portal.navigation.masthead.war for ideal time out.

I have placed custom.js in webcontent/scripts folder and in headeriview.jsp i have given src path as "irj/portalapps/com.sap.portal.navigation.masthead/scripts/custom.js"

and changed the logoff() method as performLogOff() in custom.js but this is not working.

Please helpme in this regard.

Thanks,

Santosh.

sambaran
Explorer
0 Kudos

For classic framework page standard logoff() method provided into the headeriview.jsp should work.

Write your java script code at the end of headerivew.jsp and use the same logoff method .

Regards,

Sambaran Chakraborty

Former Member
0 Kudos

Hi Sambaran Chakraborty,

Can you please let me know if we can migrate the Classic Framework masthead from 7.01 to 7.31 .

If Yes can you let me know the process for that.

Thanks and Regards,

Krishna

sambaran
Explorer
0 Kudos

I am not sure about that.

But you can try to use PAR migration tool to convert masthead PAR into a web resource project and then deployed it to 7.31 portal.

Once it deployed it will give you the masthead page to verify.

As 7.01 and 7.31 has some java architectural difference, I doubt how good it will work.

But give it a try. Best of luck !

Regards,

Sambaran

Former Member
0 Kudos

I will Try and see...I know about the Par migration Process....I just wanted to know if anyone has been successful in Doing it....!!!!!

Former Member
0 Kudos

Hi Sambaran,

I am trying to implement the same code in 7.4 Poral and its working fine when a user is idle. Unfortunately i am facing some issues even though the user is working in the content area  it triggers a logout. Can you please help me on this,which event i need to subscribe for content area?