mibuso.com

Microsoft Business Solutions online community
It is currently Sat May 18, 2013 4:14 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: [Solved] How to limit Navision login session (Nav 4 SP3)
PostPosted: Thu Jun 12, 2008 4:38 am 
Offline

Joined: Wed Apr 27, 2005 4:18 am
Posts: 59
Location: Singapore
Country: Singapore (sg)
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.


Last edited by nasheer on Fri Jun 13, 2008 3:56 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 12, 2008 4:54 am 
Offline

Joined: Sat Dec 23, 2006 2:32 am
Posts: 201
Location: Malacanang
Country: Philippines (ph)
instead of using
Quote:
MESSAGE('You have no permission to login as all sessions are being used.');


try this.
Quote:
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 12, 2008 5:17 am 
Offline

Joined: Wed Apr 27, 2005 4:18 am
Posts: 59
Location: Singapore
Country: Singapore (sg)
Hi Sendoh

I tried using ERROR command as you mentioned. But still the same.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 12, 2008 10:12 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
this is a known problem in codeunit 1.

try first to put your message, then add ERROR('') after it. Like this:
Code: Select all
MESSAGE('You have no permission to login as all sessions are being used.');
ERROR(''); 


I was struggling with this myself in the past (here).

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 12, 2008 10:47 am 
Offline

Joined: Wed Apr 27, 2005 4:18 am
Posts: 59
Location: Singapore
Country: Singapore (sg)
Hi Waldo

Thanks for your message. If i remove the message and error commands, the code works. But how to display the warning message?

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 12, 2008 10:56 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
Didn't say you have to remove it :| .

What I meant was, try to use this code (I only added one line)
Code: Select all
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;

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 12, 2008 11:17 am 
Offline

Joined: Wed Apr 27, 2005 4:18 am
Posts: 59
Location: Singapore
Country: Singapore (sg)
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).

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 12, 2008 12:47 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
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:
Code: Select all
  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:
Code: Select all
  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:
Code: Select all
  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.

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 12, 2008 6:08 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Thu Oct 16, 2003 8:50 am
Posts: 12265
Location: Brno
Country: Czech Republic (cz)
You can use the Popup function of the WSH to show some dialog when closing the company... ;-)

_________________
Kamil Sacek
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.


Top
 Profile E-mail WWW  
 
 Post subject: [solved}
PostPosted: Fri Jun 13, 2008 3:55 am 
Offline

Joined: Wed Apr 27, 2005 4:18 am
Posts: 59
Location: Singapore
Country: Singapore (sg)
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 Regards


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 13, 2008 9:34 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
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:
Code: Select all
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>

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 13, 2008 10:23 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Thu Oct 16, 2003 8:50 am
Posts: 12265
Location: Brno
Country: Czech Republic (cz)
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:
Code: Select all
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...)

_________________
Kamil Sacek
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.


Top
 Profile E-mail WWW  
 
 Post subject:
PostPosted: Fri Jun 13, 2008 10:26 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
I didn't now the WShell Popup, so I learned something new today. \:D/
Thanks, Kine.

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 13, 2008 10:37 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Thu Oct 16, 2003 8:50 am
Posts: 12265
Location: Brno
Country: Czech Republic (cz)
Every day you can find something to learn... :-D and mainly on MiBuSo... 8)

_________________
Kamil Sacek
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.


Top
 Profile E-mail WWW  
 
 Post subject:
PostPosted: Fri Jun 13, 2008 10:40 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2013 attendee

Joined: Fri Dec 06, 2002 11:50 am
Posts: 3390
Location: Kontich, Belgium
Country: Belgium (be)
True. But I don't have too much time any more. Only now, when i'm sick :)

_________________

Eric Wauters
MVP - Microsoft Dynamics NAV
My blog


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: