Hi,
I would like to know, how to limit user login connections to the server? (Using NAV 4 SP3)
If the user login sessions to the Database exceeds 3, how to close/logout programatically the last (4 th) user session.
I tried the below code in the Codeunit1 - 'LogInStart'
tblSession.RESET;
tblSession.SETRANGE("My Session",TRUE);
IF tblSession.FIND('-') THEN
BEGIN
fldUserLimit := 0;
tblDBUserLimit.RESET;
tblDBUserLimit.SETRANGE("Database Name",tblSession."Database Name");
IF tblDBUserLimit.FIND('-') THEN
fldUserLimit := tblDBUserLimit."No. Users Login";
tblSession1.RESET;
tblSession1.SETRANGE("Database Name",tblSession."Database Name");
IF tblSession1.FIND('-') THEN
NoOfLogins := tblSession1.COUNT;
END;
IF NoOfLogins > fldUserLimit THEN BEGIN
LogInEnd;
MESSAGE('You have no permission to login as all sessions are being used.');
CREATE(WSHell);
WSHell.SendKeys('%{F4}');
CLEAR(WSHell);
END;
My coding not working. The message prompts correctly, but still goes in.
Any one can help me.
Regards
Nasheer.
0
Answers
try this.
I didn't Test that hope will work..
be smart before being a clever.
I tried using ERROR command as you mentioned. But still the same.
try first to put your message, then add ERROR('') after it. Like this:
I was struggling with this myself in the past (here).
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Thanks for your message. If i remove the message and error commands, the code works. But how to display the warning message?
Regards
What I meant was, try to use this code (I only added one line)
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Thank you very much for your support. I tried as you mentioned, but still not working. And if I remove the message, it works, not allow to login (close the Navision Client).
Regards
I decided just to test your code, and you were right. Strange behaviour in CU1, isn't it ... . Allthough I remember that we built a similar functionality in a 3.7 database. Never had problems with it (just with an ERROR statement).
Well, I just see a few (definitely not nice) solutions. You want to show the message, and to close your client afterwards. The ERROR doesn't work, and the MESSAGE is not useful (is always shown at the end of the process).
So, the only things you have (from the op of my head) is:
- a dialog
- a CONFIRM
- a custom form
Using a dialog could be something like:
Using a CONFIRM gives you the advantage that the user must push a button to close it - and has read whatever was going on: Also not really nice, because of the fact that you get "yes/No" buttons, which don't make sense... .
For the custom form, you can build your own form with that OK-button, and the message in a caption or whatever. You code would look something like:
These are just a few suggestions. I'm sure there are better ones.
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Thanks for your support. I tried Waldo's suggesstions first.
Using CONFIRM command, still the user able to login.
And tried using Dialog, it works.
I prefered Kine's suggesstion to use WSH Popup, it works fine.
Thank you once again for your help to solve the problem.
Best Regards
I tested the Popup and it works perfectly. Definitely the best solution. For the people who care:
=D>
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
And you can add two more parameters to set the title of the dialog to something meaningful... 8) (but you need to use two variables...)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Thanks, Kine.
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
[Topic moved from Navision forum to Navision Tips & Tricks forum]
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!