Allow only one current session per user

alyssasalyssas Member Posts: 28
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 Member Posts: 107
    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 Member Posts: 28
    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 Member, Moderator, Administrator Posts: 3,633
    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. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • alyssasalyssas Member Posts: 28
    Great - thanks for all your help! Was able to successfully code today...
  • JeffJeff Member Posts: 1
    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 Member Posts: 107
    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 Member Posts: 589
    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 Member Posts: 3
    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 Member Posts: 21
    Hi, you should modify the code unit 40 (LogInManagement)
  • mucamuca Member Posts: 42
    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.