Get Client computer name/IP Address from Server Side

BBlueBBlue Member Posts: 90
Hi,

I made a development which uses Navision Socket Bus Adaptor. On the server (native) there is a CU that searches for idle users on fixed intervals and if finds, it sends messages to one computer name. It's something like:
OutMsg := ComCom.CreateoutMessage('Sockets://Computer1:8079');
OutS := OutMsg.GetStream();
OutS.WRITE(User ID);

On the clients I have a single instance CU that receives the message and closes that client.

The problem is that I don't know the computer name/IP address of the idle user from Nav server :-k . Is there any way to find the computer name asociated with one session in Nav? The command ENVIRON('clientname') works only if the client is connected through remote. Or, is there any way to send messages through sockets to the entire network? This way, transmitting the userid from the server, only the client with that ID will close.

Thanks in advance and have a nice day!
//Bogdan

Comments

  • ara3nara3n Member Posts: 9,256
    If you are on sql. that info is on session table.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • BBlueBBlue Member Posts: 90
    edited 2007-11-02
    I'm not on SQL but reading
    http://www.mibuso.com/forum/viewtopic.php?t=14707, I found a solution. When every client opens a company I send the computer name into a temporary table and then I use this information for automatically close idle clients.

    Thanks garak.
    //Bogdan
  • kinekine Member Posts: 12,562
    But this solution will not work when someone runs two client on one PC or you are using Terminal services for connection. How do you want to solve that?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • BBlueBBlue Member Posts: 90
    The solution is intended for a small category of users which certainly won't use connection through remote. As for opening two clients from the same machine... I have to find a solution... :-k
    //Bogdan
  • BBlueBBlue Member Posts: 90
    I reopen my issue as I realized my solution wasn't so reliable. Even if it somehow worked, it's not a good idea to use a table that stores computer name and Session ID and after using this info erase the line from the table.
    So, what I want to do: On the server side (Navision Database Server), I have a CU that periodically searches for idle clients in Session table. If it finds idle clients, I want to send messages to all the network with the idle client user ID. On the clients I have single instance CU that verifies if the user ID sent is the current USERID, then closes that client (I send a dos command, "taskkill /IM fin.exe" to close the Nav client).
    I tried all the communication methods from Navision SDK and closely followed the exemples from devguide.chm:

    1) Navision Socket Bus Adaptor - it works well only if you know the computer name associated with a session, but I don't have this info at server side (Navision Database Server has incorrect info about host name in Session table). The command is:
    OutMsg := ComCom.CreateoutMessage('Sockets://Computer1:8079');
    
    If I send message to a closed computer or one that doesn't exist, the socket bus adaptor returns an error message. I guess through sockets you cannot send messages to all the network in Nav... :cry:

    2) Navision Named Pipe Bus Adaptor - works well only if using two clients on the same PC (one sends the message and the other receives it). But on the network it doesn't work. If I have clients computers with single instance CU and send a message from a client on the server, that client crashes:
    OutMsg := CC.CreateoutMessage('Named Pipe://\\Servername\pipe\Test');
    Outstrm := OutMsg.GetStream; //it crashes here
    

    3) Navision MSMQ Bus Adaptor (apparently the best communication interface) - I created a private queue (works with public queue also) on the server then send a message from the server. The problem is that only the first client with single instace CU that receives the message processes it, then the message is destroyed. Is there any way to keep the message alive after reaching the first client through the network so that it reaches to all the clients? #-o

    I hope I didn't bored you with my post but I'm stuck with these communication components...
    //Bogdan
  • SavatageSavatage Member Posts: 7,142
    So you can close the idle session but you are fighting with sending a message to that machine?

    "your session has timed out" or something like that?

    Note; I also remember a post about only allowing 1 login per user but I can't find it rightr now.

    I believe it used CU1 to check if the username was already logged in and wouldn't allow it to login again. Perhaps someone can find it.

    We use www.autocloseidle.com (not as sophisticated as Expandit's solution)
    also
    Expandit Client Manager is available
    http://www.expandit.com/templates/expan ... log_id=635
      Supports Navision versions 1.10 to 4.0 SP1 List user name of active Navision users sessions. Identify computers that run Navision user sessions. List running user sessions. Shows process information for user sessions. Send messages to Navision users. Shut down individual or groups of user sessions. Terminate user sessions running on remote machines. Central management of ExpandIT Client Control configurations. 99 user group option sets. Limit number of sessions per user for one user or groups of users. Allows multiple installations of ExpandIT Client Manager. Control period of inactivity before log off. Set time for automatic shutdown of Navision user sessions. Show time left before users sessions are automatically terminated. Easy to install and maintain.

    =P~ =P~ =P~ =P~
  • BBlueBBlue Member Posts: 90
    edited 2007-11-02
    Closing an idle session is easy, you can delete the line from Session table. My intention is to completely close the idle Nav client. Based on these messages I send, a function fires in the client single instance CU that completely closes that client (it closes all fin.exe processes on that machine :mrgreen: ). The function is:


    WshShell Automation 'Windows Script Host Object Model'.WshShell
    Command Text 250
    WindowStyle Variant
    WaitOnReturn Variant
    ReturnCode Integer
    Str Text 100

    Str := 'taskkill /IM fin.exe';
    Command := STRSUBSTNO('%1 /c' +Str,ENVIRON('COMSPEC'));
    WindowStyle := 0;
    WaitOnReturn := TRUE;
    IF ISCLEAR (WshShell) THEN
      CREATE(WshShell);
    ReturnCode := WshShell.Run(Command, WindowStyle, WaitOnReturn);
    CLEAR(WshShell);
    

    That is why I want to send messages with the idle client ID.
    //Bogdan
  • BBlueBBlue Member Posts: 90
    Thanks for your input. I think I know that post, though I can't find it now. It has some code in function LogInStart in CU1 that verifies how many sessions the current user has. If it has one, then another isn't allowed. But that doesn't help me, unfortunately. I need to find a way to send a message (that contains a specific idle network client user ID) from one client on the server to the clients in the network, so the single instance CU from network clients can process the message and close a certain client if the user ID from message is the current user ID... ](*,)
    //Bogdan
Sign In or Register to comment.