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
If the user didnt click ok the session remains active!