Solved

Retrieve login, IP, and computer name of remote desktop

Posted on 2009-05-13
6
1,706 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
  • 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 300 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

My previous article  (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_Server_2008/A_4466-A-beginners-guide-to-installing-SCCM2007-on-Windows-2008-R2-Server.html)detailed one possible method to get SCCM 2007 installed an…
Have you considered what group policies are backwards and forwards compatible? Windows Active Directory servers and clients use group policy templates to deploy sets of policies within your domain. But, there is a catch to deploying policies. The…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now