Dynamics NAV

Friday, 2 January 2015

How to restrict multiple logins for the same user ID

Some time we login multiple times with same user ID,but if we want to restrict this,please follow the below

In NAV 2013 and Later , Active Sessions (Table ID - 2000000110) gives 

 all the active session into the database.

For Restricting multiple Login we can use Codeunit 40 - LogInManagement.

So let's see how we can achieve this -

1. Design Codeunit 40, Navigate to Function CompanyOpen().

2. Append Below Lines as below -

the standard code looks like below
---------------------------------------------------
IF GUIALLOWED THEN
  LogInStart;
---------------------------------------------------

After
---------------------------------------------------
//Add code here BEGIN
ActiveSession.SETRANGE("User ID",USERID);
ActiveSession.SETRANGE("Client Type",ActiveSession."Client Type"::"Windows Client");
IF ActiveSession.COUNT > 1 THEN
  ERROR('You are Already Logined');
//Add code here END

IF GUIALLOWED THEN
  LogInStart;
---------------------------------------------------

The Client Type have following Options -
Windows Client,SharePoint Client,Web Service,Client Service,NAS,Background,Management Client,Web Client,Unknown

Above Code will Stop Windows Client to use multiple session with same User ID.

How it executes:

I will get the below error message while runnning RTC client second time which my first RTC client is already opened.



No comments:

Post a Comment