Kill Session for Duplicate Login

Vineeth.RVineeth.R Member Posts: 121
Hi Friends,

My customer do not want any user to login twice to navision with his/her ID.

I decided the write the code in Codeunit 1 - CompanyOpen function. If i test the below code by logging in as 'SA' UserID then the code works and the duplicate session is killed. But the code fails if i login twice with any other user login.

I think since other than 'SA' nobody can see the session records the code is not working. Any suggestion to overcome this?

CREATE(WinShell);
LSession.RESET;
LSession.SETCURRENTKEY("Login Date","Login Time");
LSession.SETRANGE("User ID",USERID);
LSession.SETFILTER("Database Name",'%1','Demo Database NAV (6-0)');
IF LSession.COUNT > 1 THEN BEGIN
IF LSession.FINDLAST THEN
WinShell.SendKeys('%{F4}');
END;


Pls help.
Thanks and Regards
Vineeth.R

Comments

  • VonHazzelVonHazzel Member Posts: 1
    Hi Vineeth.R

    Do you get an error when you’re loggin in with login nr2.?

    Can’t you just delete the record in the session table instead of using winshell?
    IF LSession.FINDLAST THEN
      LSession.Delete(True)
    

    Just an idea :wink:
  • Vineeth.RVineeth.R Member Posts: 121
    Hi VonHazzel,

    ok i will try that.

    problem is when normal user other than 'SA' if try to login twice the below cose does not work from his login because he cannot access the session table. So the below written code does not work.

    How to make it work?

    Thanks
    Vineeth
    Thanks and Regards
    Vineeth.R
  • ssinglassingla Member Posts: 2,973
    How about using NAS to check duplicate login and kill session.
    CA Sandeep Singla
    http://ssdynamics.co.in
Sign In or Register to comment.