How to limit multisessions logins in NAV (from NAV 4 to NAV 2009 R2 Classic)

How to limit multisessions logins in NAV (from NAV 4 to NAV 2009 R2 Classic)

OnCompanyOpen_Trigger

Variables
Name  DataType Subtype
recUser Record  User
recSessions Record  Session
CanLogin Boolean

//MultiLogin Check

IF recUser.GET(UPPERCASE(USERID)) THEN
BEGIN
recSessions.SETRANGE(“User ID”, UPPERCASE(USERID))   ;  //utente connesso
recSessions.SETRANGE(“Application Name”,’Microsoft Dynamics NAV Classic client’);   //controllo solo per classic client
recSessions.SETRANGE(“Login Type”, recSessions.”Login Type”::Database);  //solo per utenti DB
IF recSessions.COUNT > 1 THEN
IF recUser.MultiLogin = FALSE THEN  //se NO multilogin esce
BEGIN
//MESSAGE(‘Utente sta usando già 1 Licenza NAV, MultiLogin NON Permesso per questo utente’);
CloseDB;  //Chiude le session NAV con WSHELL Automation
END;
END;

Function CloseDB()

// Using WShell Automation

Variables
Name DataType Subtype Length
WSHell Automation ‘Windows Script Host Object Model’.WshShell

CREATE(WSHell);
WSHell.Popup(‘Utente sta usando già 1 Licenza NAV, MultiLogin NON Permesso per questo utente’);
WSHell.SendKeys(‘%{F4}’);
CLEAR(WSHell);
End Function

One thought on “How to limit multisessions logins in NAV (from NAV 4 to NAV 2009 R2 Classic)

  • 24 May 2016 at 3:06 PM
    Permalink

    If the user didnt click ok the session remains active!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Enjoy this blog? Please spread the word :)

%d bloggers like this: