How many times users receive the message “you can’t login.. you haven’t more licenses available… in RTC\Windows Client ??
Always ! ..users usually try to connect many times in NAV, consuming more that 1 license !! licenses are costs ! Microsoft Philosophy is: buy more licenses … my philosophy is: buy new licenses but.. before force logins limitations for some users: ex: CEO can have multiple logins, operational people absolutely NO !!
NAV 2013 and Later
From NAV 2013 Microsoft created a table named: Active Sessions – Table ID 2000000110 This table contains information about all the active sessions, showing Connected Client Type\PC and Users)
Take a look to my previous post about “ALL ABOUT” Kill (In)active Sessions when “no more licenses”, with the VB.NET app in this post, you can show Client Type\PC and Connected User from this app to decide “who is the user” than try to use more than one NAV session.
Starting from User Setup Table
You can add a boolean field “Multilogin” to User Setup Table (table 91)” ; with this boolean field you can check if user can login more times in NAV instead of only one time.
User Setup – Table ID 91 User Setup
Before you need to add the new field “Multilogin” on Page “User Setup” (…or comment C/AL check code… you can’t login in anyway if you haven’t configured your user in this table)
..We can’t use System Table User.. because is used by System on Login process .. if you try to use this table you can’t start Windows Client…
To Restrict multiple logins we can use Login Codeunit
Codeunit 40 – LogInManagement
This codeunit is ht first fired on Login Time and I can add C/AL code here to trap user logins.
Steps: Open Codeunit 40, goto function CompanyOpen()
In CompanyOpen function add two new local variables: locUser and locActiveSessione
Modify the CompanyOpen function in this way:
C/AL Code “Before”
CompanyOpen()
IF GUIALLOWED THEN LogInStart; C/AL Code “After”
CompanyOpen()
locUser.GET(UPPERCASE(USERID));
IF NOT locUser.Multilogin THEN
BEGIN
locActiveSession.RESET;
locActiveSession.SETRANGE(“User ID”,UPPERCASE(USERID));
locActiveSession.SETRANGE(“Client Type”, locActiveSession.”Client Type”::”Windows Client”); //For RTC\Windows Clients
IF locActiveSession.COUNT > 1 THEN
ERROR(‘You are currently logged in NAV, you can’t have more sessions!’);
END;
IF GUIALLOWED THEN
LogInStart;
// Register all Microsoft Dynamics CRM connection strings
IF CRMConnectionSetup.GET THEN
CRMConnectionSetup.UpdateAllConnectionRegistrations;
Results
System abort login codeunit and display the Error Message “’You are currently logged in NAV, you can’t have more sessions!”; you can use\trap also others login types: ex: Web Client, Web Service, Background Sessions and so on.
Another Nice Feature
You can decide also “how many sessions” each user can launch adding a “No. Sessions” field in User Table.
C/AL Code
CompanyOpen()
locUser.GET(UPPERCASE(USERID));
IF NOT locUser.Multilogin THEN
BEGIN
locActiveSession.RESET;
locActiveSession.SETRANGE(“User ID”,UPPERCASE(USERID));
locActiveSession.SETRANGE(“Client Type”, locActiveSession.”Client Type”::”Windows Client”); //For RTC\Windows Clients
IF locActiveSession.COUNT > 1 THEN
ERROR(‘You are currently logged in NAV, you can’t have more sessions!’);
END
ELSE
BEGIN
locActiveSession.RESET;
locActiveSession.SETRANGE(“User ID”,UPPERCASE(USERID));
locActiveSession.SETRANGE(“Client Type”, locActiveSession.”Client Type”::”Windows Client”); //For RTC\Windows Clients
IF locActiveSession.COUNT > locUser.”No. Sessions” THEN
ERROR(‘You are currently logged in NAV, you can’t have more than ‘ + FORMAT(locActiveSession.COUNT-1) + ‘ sessions!’);
END;
IF GUIALLOWED THEN
LogInStart;
// Register all Microsoft Dynamics CRM connection strings
IF CRMConnectionSetup.GET THEN
CRMConnectionSetup.UpdateAllConnectionRegistrations;
Results
Bingo !
