Allow only one current session per user

alyssasalyssas Posts: 28Member
edited 2004-03-19 in Navision Attain
Hello,

My client would like to implement code to only allow a user to login to Navision once (one current session at a time.) I've reviewed posts related to this topic, but they mostly seem to deal with being able to kill an additional session. I want to add code to the login form/table to check the Database information sessions table to see if the user is already logged in. However, I can't figure out where the source code is for the current sessions or what objec to add the logic to kick off the check when the user logs in. Any help would be appreciated!

Thanks!
Alyssa

Comments

  • bostjanlbostjanl Posts: 107Member
    alyssas wrote:
    Hello,

    My client would like to implement code to only allow a user to login to Navision once (one current session at a time.) I've reviewed posts related to this topic, but they mostly seem to deal with being able to kill an additional session. I want to add code to the login form/table to check the Database information sessions table to see if the user is already logged in. However, I can't figure out where the source code is for the current sessions or what objec to add the logic to kick off the check when the user logs in. Any help would be appreciated!

    Thanks!
    Alyssa

    You should put your code call in CoduUnit 1 - ApplicationManagement in triger/function CompanyOpen Or LogInStart.

    In your code you can check sesions with help of system table 2000000009 - Sesion.


    bostjan
  • alyssasalyssas Posts: 28Member
    I don't see table Session (2000000009) - I'm using a 3.10B database. How do I gain access to it if it isn't in the object designer?

    Thanks!
    Alyssa
  • Luc_VanDyckLuc_VanDyck AartselaarPosts: 3,632Member, Moderator, Administrator
    It's a virtual table. That means this table is not visible in the object designer, but it can be used as a subtype for record variables.
    Create a C/AL global variable recSession, with DataType Record and Subtype Session. When you press the lookup on Subtype, you'll see all virtual tables.
    No support using PM or e-mail - Please use this forum.
    NAV TechDays 2020: 19 & 20 November 2020, Antwerp (Belgium)
  • alyssasalyssas Posts: 28Member
    Great - thanks for all your help! Was able to successfully code today...
  • JeffJeff Posts: 1Member
    bostjanl wrote:
    alyssas wrote:
    Hello,

    My client would like to implement code to only allow a user to login to Navision once (one current session at a time.) I've reviewed posts related to this topic, but they mostly seem to deal with being able to kill an additional session. I want to add code to the login form/table to check the Database information sessions table to see if the user is already logged in. However, I can't figure out where the source code is for the current sessions or what objec to add the logic to kick off the check when the user logs in. Any help would be appreciated!

    Thanks!
    Alyssa

    You should put your code call in CoduUnit 1 - ApplicationManagement in triger/function CompanyOpen Or LogInStart.

    In your code you can check sesions with help of system table 2000000009 - Sesion.


    bostjan

    Hello,
    I'm interested by this solution but when Navision carries out these functions, the session already exists.
    Is it possible to check current sessions before the creation of a new session?
    If not, do you request with the user to disconnect itself or is it possible to disconnect it automatically?
    Thank you by advance for your answers
    Jeff
  • bostjanlbostjanl Posts: 107Member
    Jeff wrote:
    bostjanl wrote:
    alyssas wrote:
    Hello,

    My client would like to implement code to only allow a user to login to Navision once (one current session at a time.) I've reviewed posts related to this topic, but they mostly seem to deal with being able to kill an additional session. I want to add code to the login form/table to check the Database information sessions table to see if the user is already logged in. However, I can't figure out where the source code is for the current sessions or what objec to add the logic to kick off the check when the user logs in. Any help would be appreciated!

    Thanks!
    Alyssa

    You should put your code call in CoduUnit 1 - ApplicationManagement in triger/function CompanyOpen Or LogInStart.

    In your code you can check sesions with help of system table 2000000009 - Sesion.


    bostjan

    Hello,
    I'm interested by this solution but when Navision carries out these functions, the session already exists.
    Is it possible to check current sessions before the creation of a new session?
    If not, do you request with the user to disconnect itself or is it possible to disconnect it automatically?
    Thank you by advance for your answers
    Jeff

    Hi!

    We just do ERROR msg and that it. I didn't look for automatic disconect.


    Bostjan
  • eromeineromein Posts: 589Member
    For what reason do you want this functionality?
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • zarahjaysmithzarahjaysmith Posts: 3Member
    Hi can someone please tell me what code i would need to put in to CoduUnit 1 - ApplicationManagement in triger/function CompanyOpen Or LogInStart to make this work?
  • pavithrap0992pavithrap0992 Posts: 21Member
    Hi, you should modify the code unit 40 (LogInManagement)
  • mucamuca Posts: 40Member
    edited 2016-11-11
    Session Record TableID=2000000009

    Session.SETRANGE("User ID",USERID);
    Session.SETRANGE("My Session",FALSE);
    IF Session.FIND('-') THEN
    ......

    Then You can use MESSAGE (Warning) or ERROR (user can not open navision data)

    but in any case there session record will be in navision in case that is no possible to delete entries in table Session. (This is possible starting Navision version 4)

    @pavithrap0992 : in Navision Attain there is no codeunit 40 (LogInManagement)! Please read thread category.
Sign In or Register to comment.