Options

Log off users after period of inactivity

TomasTomas Member Posts: 420
NAV 4 native database (without job scheduler). No NAS neither.

Any ideas on how to kill nav user sessions without buying additional granules?

Possible ideas:
- disconnect user from network (would user session be killed, or would it remain on nav?)
- write a report that would kill inactive sessions and run it manually when needed (but here, when you need to log on in nav, and there is not enough sessions left, you will not be able to run that report)
- any other ideas?

Comments

  • Options
    JedrzejTJedrzejT Member Posts: 267
  • Options
    MalajloMalajlo Member Posts: 294
    For a beer...
    Users that have Idle timeout field empty, run CU in single instance. See better solution (if possible) at the end of post.
    OBJECT Codeunit 50004 AutoLogout
    {
      OBJECT-PROPERTIES
      {
        Date=20.10.07;
        Time=[ 9:49:19];
        Version List=AX064;
      }
      PROPERTIES
      {
        SingleInstance=Yes;
        OnRun=BEGIN
                IF NOT CREATE(Timer) THEN ;
                Timer.Interval := 60000 ; //1 minute
                Timer.Enabled := TRUE;
                Window.OPEN('AutoDisconnect startan!\(window will close automatically)') ;
                SLEEP(1500) ;
                Window.CLOSE ;
              END;
    
      }
      CODE
      {
        VAR
          Timer@1000000000 : Automation "{3B311C81-140E-11D5-8B18-00D0590B4EC5} 1.0:{3B311C92-140E-11D5-8B18-00D0590B4EC5}:'Navision Timer 1.0'.Timer" WITHEVENTS;
          Sessions@1000000002 : Record 2000000009;
          users@1000000001 : Record 91;
          Window@1000000004 : Dialog;
    
        EVENT Timer@1000000000::Timer@1(Milliseconds@1000000000 : Integer);
        BEGIN
          users.SETFILTER(users."Idle Timeout",'<>''''') ;
          IF users.FINDFIRST THEN
            REPEAT
              Sessions.SETFILTER(Sessions."User ID",'*'+users."User ID") ;
              IF Sessions.FINDFIRST THEN
                IF Sessions."Idle Time" > users."Idle Timeout" THEN
                  BEGIN
                    Sessions.DELETE ;
                    MESSAGE('User %1 has been disconnectedafter %2.',users."User ID",users."Idle Timeout") ;
                  END ;
            UNTIL users.NEXT = 0 ;
          IF USERID = 'TEST' THEN MESSAGE('Timer dela') ;
        END;
    
        EVENT Timer@1000000000::TimerError@2(ErrorString@1000000000 : Text[1024]);
        BEGIN
        END;
    
        BEGIN
        END.
      }
    }
    

    Added field in T:91
    Field No. Field Name Data Type Length Description
    69002 Idle Timeout Duration

    Add code in CU:1, in LoginStart
    ...
        StartOutlookSyncronization;
    END;
    
    IF FORMAT(UserSetup."Idle Timeout") = '' THEN CODEUNIT.RUN(CODEUNIT::AutoLogout) ;  //AX064
    
    StartOutlookSyncronization()
    OLAppMgmt.StartSynchronize;
    
    LogInEnd()
    IF LogInWorkDate <> 0D THEN
      IF LogInWorkDate = LogInDate THEN
    ...
    

    It is better to use NAS, since every minute session idle time is reset to zero.
    Using NAS idle time of user is not affected.
  • Options
    TomasTomas Member Posts: 420
    I understand that it is better to kill sessions using NAS (and easier too), however this time - I need to come up with ideas to do it without NAS.

    However, ideas outside of navision doesn't seem to be right.
  • Options
    MalajloMalajlo Member Posts: 294
    Described solution works without NAS.
    But you must left Idle time blank only on users that are working all the time and set Idle time for users that are "distressed" and continuously leave session active.
    Forgot to mention, you must add read/delete permission on table Sessions.

    You have another way to solve timings.
    You can dedicate one user to do disconnects. Use windows Authentication and start fin.exe with Task scheduler. Add wsh script (sendkeys) at the end to close client.
    But if no session is available, then the client will stop at error and will not close. Using shell command tasklist /kill (or pslist /kill) before running task will solve that problem.
  • Options
    TomasTomas Member Posts: 420
    Malajlo wrote:
    Described solution works without NAS.
    But you must left Idle time blank only on users that are working all the time and set Idle time for users that are "distressed" and continuously leave session active.
    Forgot to mention, you must add read/delete permission on table Sessions.

    You have another way to solve timings.
    You can dedicate one user to do disconnects. Use windows Authentication and start fin.exe with Task scheduler. Add wsh script (sendkeys) at the end to close client.
    But if no session is available, then the client will stop at error and will not close. Using shell command tasklist /kill (or pslist /kill) before running task will solve that problem.

    Thanks. I will try both of your suggested solutions.
  • Options
    ricardonuneskbcricardonuneskbc Member Posts: 3
    Hi, i tried this solution in two customers, and it works fine in one but not in other. Both are working with native db, but one increments the idle time with no limits, and the other when reaches 1 minute resets it to 0. How can this happen? Best regards.
  • Options
    MalajloMalajlo Member Posts: 294
    timer triggers after one minute and therefore it sets idle time to zero.
    If you test with same username it won't work.
    At least one user should do disconnects and others should not.
  • Options
    AmaraaAmaraa Member Posts: 153
    Hello,

    I've tried 1st solution.
    But the problem is how can I access to Session Table?

    The code unit works, but it doesn't kill the session. I think it is because I didn't do anything with the "Session" table.

    Please, advice
    Amaraa
  • Options
    JosetxoJosetxo Member Posts: 92
    Hello,

    another option is ExpandIT Client Control: http://www.expandit.com/templates/expan ... log_id=634

    But you have to pay for that...

    Regards,
    Josetxo
  • Options
    SaalekSaalek Member Posts: 181
    I Agree with Josetxo.

    I tried it in one customer and runs well. Is easy to configure and manage.

    Bye.
  • Options
    AmaraaAmaraa Member Posts: 153
    Hi guys,

    I know there is a tool ExpandIt. But I don't want to pay for this if it is can be done (not so difficult to programm).
    I guess there is a solution.

    Regards,
    Amaraa
  • Options
    SavatageSavatage Member Posts: 7,142
    another outside option is http://www.autocloseidle.com we use that
    Amaraa wrote:
    I know there is a tool ExpandIt. But I don't want to pay for this if it is can be done (not so difficult to programm).
    I guess there is a solution.
    since switchig to sql seems out of the question "NAV 4 native database (without job scheduler). No NAS neither. " :wink:
    ps . sometimes paying for a working solution is far worth the headache of coming up with one.

    you'll have to weigh the costs
      sql sheduler nas outside program
    your call

    **edit : What the list thingy doesn't work? :-k
  • Options
    David_SingletonDavid_Singleton Member Posts: 5,479
    Savatage wrote:
    ...
      sql sheduler nas outside program
    your call

    **edit : What the list thingy doesn't work? :-k
    • sql
    • sheduler
    • nas
    • outside program
    [list]
    [*]sql
    [*]sheduler
    [*]nas
    [*]outside program[/list]
    
    David Singleton
  • Options
    David_SingletonDavid_Singleton Member Posts: 5,479
    Amaraa wrote:
    Hi guys,

    I know there is a tool ExpandIt. But I don't want to pay for this if it is can be done (not so difficult to programm).
    I guess there is a solution.

    Regards,
    Amaraa

    Amaraa are you an End User or a Partner.

    If you are a customer, then you need to understand that people can't develop professional business solutions for free. These products have to be developed tested and supported. If you are a partner, then you need to consider if you are doing your customer a justice. The cost for you to research and analyze then code and test this solution will be far more than the cost of purchasing a ready made product. In the time you waste (and bill the client) for this you could be doing actual business related Navision work.
    David Singleton
  • Options
    AmaraaAmaraa Member Posts: 153
    Amaraa wrote:
    Hi guys,

    I know there is a tool ExpandIt. But I don't want to pay for this if it is can be done (not so difficult to programm).
    I guess there is a solution.

    Regards,
    Amaraa

    Amaraa are you an End User or a Partner.

    If you are a customer, then you need to understand that people can't develop professional business solutions for free. These products have to be developed tested and supported. If you are a partner, then you need to consider if you are doing your customer a justice. The cost for you to research and analyze then code and test this solution will be far more than the cost of purchasing a ready made product. In the time you waste (and bill the client) for this you could be doing actual business related Navision work.

    I'm a partner.
    And the customer asked to have a tool for auto disconnecting idle users. So, your recommendation is to suggest to the customer buying a tool for that.
    I will talk about it with them.
  • Options
    slowhandfanslowhandfan Member Posts: 56
    We have a customer licensed for just 4 users, 2 NAS's and 2 clients running SQL 2009R2. They wanted a session kill on a user for 30 miniutes of inactivity. I added some code (see below) to one of the NAS's that we use at not SQL customers running versions 5.1 and 4.3. Code works great. Had an interesting side effect on 2009R2 SQL. After 30 minutes the Session record is deleted if the client was inactive. If 2 users were idle then both session records are deleted allowing another client to connect. The 2 idle sessions appear to the user to be active. When they touch their screen the session record is restablished with no apparent interruption. If both knocked off users touch their screen they are connected. We now have 5 active users (2 NAS and 3 Cleints) while the license clearly only allows 4. If one of the cleints logs off they cannot get back in, they get the standard number of sessions exceeded. It seems like a huge license loop hole. If the seesion records are deleted through the NAS it allows other users to log on but then allows the active clients (whosw sessins records were deleted) to re-establish another session record exceeding the license limit.


    session.SETRANGE("My Session",FALSE);
    session.SETFILTER(session."Application Name",'%1','Microsoft Dynamics NAV Classic client');
    session.SETFILTER(session."Database Name",'%1','ECPNavision');
    session.SETFILTER("Idle Time",'>30 min');
    IF session.FIND('-') THEN BEGIN
    session.DELETE;
    MESSAGE('UserID %1 logged off for IDLE time', session."User ID"); // goes to event viewer
    COMMIT;
    END;
Sign In or Register to comment.