Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Retrieve login, IP, and computer name of remote desktop

Posted on 2009-05-13
6
Medium Priority
?
1,773 Views
Last Modified: 2013-11-21
How can I retrieve information about computers that are logging into Terminal Server?  I prefer to us VB6 in an exe to retrieve the data or implement a batch file. Is there any kind of log file that TS keeps that tracks remote sessions. What I am most interested in is the login name on the remote computer, the computer's IP address and name. Any other info that can be retrieved from a session would be great.
0
Comment
Question by:Mach1pro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 6

Expert Comment

by:Kentrix70
ID: 24390807
Loginname could be taken from the environment variable %username%
The name and ip-address of the host, is a little more complicated, but here is how to retrieve it in C# .NET.

http://community.citrix.com/display/xa/How+to+get+client+IP+address+and+client+hostname+using+Terminal+Services+API

I am not sure, how you would do it with VB6, as I prefer to use C# for my programming.
0
 
LVL 6

Author Comment

by:Mach1pro
ID: 24391385
That doesn't help me much. If I had a vb example that used the api, then that would probably work.
0
 
LVL 6

Accepted Solution

by:
Kentrix70 earned 1200 total points
ID: 24393025
You can get the name of the client with %clientname%

I finally found some vbcode here

http://groups.google.com/group/microsoft.public.windowsnt.terminalserver.protocols.tcpip/browse_frm/thread/7595a72b22089c76

Hope this will help you.

/Kent.
0
Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
LVL 6

Author Closing Comment

by:Mach1pro
ID: 31581189
That works by manually entering the number of a session, but is there a way to constantly poll Terminal Server to see what sessions are open so that the process can be automated?
0
 
LVL 6

Expert Comment

by:Kentrix70
ID: 24394114
You can use the utility "envtscip" from

http://www.ctrl-alt-del.com.au/CAD_Utils.htm

This utility adds an environment variable to the user session,
when it is run by the user logging on.

The variable is called %clientip%

You can then create a startup script or program,
that logs %username%, %clientname% and %clientip% to a file
or a DB (Sql Server as an example).

In that way, you will always have an updated list with this information.

Every user logging on should run a batchfile to create the environment variable.
An example is provided in the download.

I modified this example a bit by adding logging to a textfile in the end of the script.
You could of course change that according to your needs.

Just make sure, whatever you do, to let the bach script creating the environment variable run first,
so that it is created. Then you can access it like any other environment variable.

@Echo Off
:: call the client ip utility that assigns the environment variable
call "%SystemRoot%\System32\envtscip.exe"
 
::Becasue this is run in usrlogon.cmd, the environment variable cannot be broadcast to the windows shell
::thus we use the old classic Terminal Server tool ACRegL to enforce the variable during the logon script
 
"%systemroot%\Application Compatibility Scripts\ACRegL.exe" "%TEMP%\getpaths.cmd" CLIENTIP "HKCU\Volatile Environment" "CLIENTIP" ""
If Not ErrorLevel 1 Goto Cont1
Echo.
Echo Unable to retrieve path.
Echo.
Goto Finish
 
:Cont1
Call "%TEMP%\getpaths.cmd"
Del "%TEMP%\getpaths.cmd" >Nul: 2>&1
 
::The environment variable %clientip% can now be used throughout this script
::To use the environment variable %clientip% within a session run ENVTSCIP.exe in the startup of the user's session
::or the RUN section of the registry
 
::just as a test echo the variable to the screen
 
rem echo %CLIENTIP%
 
:Finish
 
echo User: %username%,Computer: %clientname%,IP: %clientip% >> \\<server>\<share>\logconnections.txt

Open in new window

0
 
LVL 6

Author Comment

by:Mach1pro
ID: 24394745
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some time ago I faced the need to use a uniform folder structure that spanned across numerous sites of an enterprise to be used as a common repository for the Software packages of the Configuration Manager 2007 infrastructure. Because the procedu…
Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip is around source server preparation. No migration is an easy migration, there is a…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question