How to limit Navision login session (Nav 4 SP3)
nasheer
Member Posts: 78
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.
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
-
instead of usingMESSAGE('You have no permission to login as all sessions are being used.');
try this.ERROR('You have no permission to login as all sessions are being used.');
I didn't Test that hope will work..Sendoh
be smart before being a clever.0 -
Hi Sendoh
I tried using ERROR command as you mentioned. But still the same.0 -
this is a known problem in codeunit 1.
try first to put your message, then add ERROR('') after it. Like this:MESSAGE('You have no permission to login as all sessions are being used.'); ERROR('');
I was struggling with this myself in the past (here).0 -
Hi Waldo
Thanks for your message. If i remove the message and error commands, the code works. But how to display the warning message?
Regards0 -
Didn't say you have to remove it
.
What I meant was, try to use this code (I only added one line)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.'); ERROR(''); //**** ONLY THIS WAS ADDED TO YOUR CODE CREATE(WSHell); WSHell.SendKeys('%{F4}'); CLEAR(WSHell); END;0 -
Hi Waldo
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).
Regards0 -
Hm,
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:dlgDialog.OPEN('You have no permission to login as all sessions are being used.'); SLEEP(1000); dlgDialog.CLOSE; CREATE(WSHell); WSHell.SendKeys('%{F4}'); CLEAR(WSHell);
Using a CONFIRM gives you the advantage that the user must push a button to close it - and has read whatever was going on:IF CONFIRM('You have no permission to login as all sessions are being used.') THEN; CREATE(WSHell); WSHell.SendKeys('%{F4}'); CLEAR(WSHell);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:FORM.RUNMODAL(FORM::"My Error Message Form"); CREATE(WSHell); WSHell.SendKeys('%{F4}'); CLEAR(WSHell);
These are just a few suggestions. I'm sure there are better ones.0 -
You can use the Popup function of the WSH to show some dialog when closing the company... ;-)0
-
Hi Waldo And Kine.
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 Regards0 -
The confirm worked with me as well .. but anyway.
I tested the Popup and it works perfectly. Definitely the best solution. For the people who care:CREATE(WSHell); //To Show the error message WSHell.Popup('You have no permission to login as all sessions are being used.'); //To close the client WSHell.SendKeys('%{F4}'); CLEAR(WSHell);
=D>0 -
Waldo wrote:The confirm worked with me as well .. but anyway.
I tested the Popup and it works perfectly. Definitely the best solution. For the people who care:CREATE(WSHell); //To Show the error message WSHell.Popup('You have no permission to login as all sessions are being used.'); //To close the client WSHell.SendKeys('%{F4}'); CLEAR(WSHell);
=D>
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...)0 -
Every day you can find something to learn... :-D and mainly on MiBuSo... 8)0
-
Another way to limit the user sessions is this : http://www.mibuso.com/howtoinfo.asp?FileID=18
[Topic moved from Navision forum to Navision Tips & Tricks forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

