By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,296 Members | 1,472 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,296 IT Pros & Developers. It's quick & easy.

Writing Session Specific Code For Windows 2003 Terminal Server Session

P: n/a
OHM
Hi peoples,

I dont know where to place this question, so as I know you guys are all
resourceful experts, I thought I would try here.

I am writing some code which will be run usingh remote desktop ( On windows
2003 Server ), I need to determine in the code the machine name and
username. If I use GetUsername and GetMachineName, it simply gives me the
name of the currently logged on user ( at the Server ) and the Servers
Machine Name.

Any Ideas ?

Regards - Terry
Nov 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi Terry,

I knew this was your name from the past however I was not sure.

Did you already try this for the user (I do not know if it works on a
terminal server however it seems so obvious for me), maybe you can get his
standard workstation as well for that however that I do not know direct.

Imports System.Security.Principal

AppDomain.CurrentDomain.SetPrincipalPolicy(Princip alPolicy.WindowsPrincipal)
Dim WinPrincipal As WindowsPrincipal = CType(Thread.CurrentPrincipal,
WindowsPrincipal)
Dim user As String = WinPrincipal.Identity.Name

Cor
Nov 20 '05 #2

P: n/a
OHM
Thanx Cor, I'll give it a go and see what happens, I also need to get the
calling machine name, do you have any ideas on this ?

OHM

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Hi Terry,

I knew this was your name from the past however I was not sure.

Did you already try this for the user (I do not know if it works on a
terminal server however it seems so obvious for me), maybe you can get his
standard workstation as well for that however that I do not know direct.

Imports System.Security.Principal

AppDomain.CurrentDomain.SetPrincipalPolicy(Princip alPolicy.WindowsPrincipal) Dim WinPrincipal As WindowsPrincipal = CType(Thread.CurrentPrincipal,
WindowsPrincipal)
Dim user As String = WinPrincipal.Identity.Name

Cor

Nov 20 '05 #3

P: n/a
Hi Terry,

I do not understand your meaning very well. When we terminal to a remote
terminal server, all the process run in the terminal session is just like
we do when we logon to the terminal server locally. So if we call the
Getusername and getmachinename we will get the same result just as we do
locally on the server.

So can you tell me what do you want to do? What is your expected behavior?

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4

P: n/a
OHM
Hi Peter,

Basically we need to find the name of the User and the Netbios machine name
who has logged on to the terminal server. Ideally, the solution should be a
VB6 solution because thats what the code is written in, but if we can only
find a solution in .NET then we can user interop to get the info.

Cheers - OHM


""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:4T**************@cpmsftngxa10.phx.gbl...
Hi Terry,

I do not understand your meaning very well. When we terminal to a remote
terminal server, all the process run in the terminal session is just like
we do when we logon to the terminal server locally. So if we call the
Getusername and getmachinename we will get the same result just as we do
locally on the server.

So can you tell me what do you want to do? What is your expected behavior?

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #5

P: n/a
Hi OHM,

Can you give me a message when using that loggin information helps, I am
currious about that of course, theoratical it should work because it is the
principal who is using the application on terminal server.

However you never know.

Cor
Nov 20 '05 #6

P: n/a
OHM
Hi Cor,

Sorry I have not been able to try this out yet because I cant get to the
server, as soon as I have I will get back to you.

Regards - OHM
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Ow**************@TK2MSFTNGP09.phx.gbl...
Hi OHM,

Can you give me a message when using that loggin information helps, I am
currious about that of course, theoratical it should work because it is the principal who is using the application on terminal server.

However you never know.

Cor

Nov 20 '05 #7

P: n/a
OHM,
As Peter suggests, when you log into Terminal Server, the Terminal Server IS
the netbois machine name the user is logged into!

Do you mean the client PC where the Terminal Server client is running?

I have not tried it, but the WTSQuerySessionInformation API looks promising.
To get information from Terminal Server I understand you need to use
Terminal Services, which can be found at "Windows Development - Windows Base
Services - Terminal Services" it part of the Win32 API set. I really don't
know if the above is already exposed in the Framework or not.

Hope this helps
Jay
"OHM" <Me@NoWhere.Com> wrote in message
news:uz**************@tk2msftngp13.phx.gbl...
Hi Peter,

Basically we need to find the name of the User and the Netbios machine name who has logged on to the terminal server. Ideally, the solution should be a VB6 solution because thats what the code is written in, but if we can only
find a solution in .NET then we can user interop to get the info.

Cheers - OHM


""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:4T**************@cpmsftngxa10.phx.gbl...
Hi Terry,

I do not understand your meaning very well. When we terminal to a remote
terminal server, all the process run in the terminal session is just like we do when we logon to the terminal server locally. So if we call the
Getusername and getmachinename we will get the same result just as we do
locally on the server.

So can you tell me what do you want to do? What is your expected behavior?
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no

rights.


Nov 20 '05 #8

P: n/a
OHM
Thats exactly what I was looking for.

Many Thanks Jay

OHM
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ui**************@TK2MSFTNGP10.phx.gbl...
OHM,
As Peter suggests, when you log into Terminal Server, the Terminal Server IS the netbois machine name the user is logged into!

Do you mean the client PC where the Terminal Server client is running?

I have not tried it, but the WTSQuerySessionInformation API looks promising. To get information from Terminal Server I understand you need to use
Terminal Services, which can be found at "Windows Development - Windows Base Services - Terminal Services" it part of the Win32 API set. I really don't
know if the above is already exposed in the Framework or not.

Hope this helps
Jay
"OHM" <Me@NoWhere.Com> wrote in message
news:uz**************@tk2msftngp13.phx.gbl...
Hi Peter,

Basically we need to find the name of the User and the Netbios machine name
who has logged on to the terminal server. Ideally, the solution should be a
VB6 solution because thats what the code is written in, but if we can only find a solution in .NET then we can user interop to get the info.

Cheers - OHM


""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:4T**************@cpmsftngxa10.phx.gbl...
Hi Terry,

I do not understand your meaning very well. When we terminal to a remote terminal server, all the process run in the terminal session is just

like we do when we logon to the terminal server locally. So if we call the
Getusername and getmachinename we will get the same result just as we do locally on the server.

So can you tell me what do you want to do? What is your expected behavior?
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no

rights.



Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.