468,484 Members | 1,543 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,484 developers. It's quick & easy.

Writing Session Specific Code For Windows 2003 Terminal Server Session

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
8 2495
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
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
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
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
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
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
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
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.

Similar topics

3 posts views Thread by Geoff Winsor | last post: by
1 post views Thread by mwolf | last post: by
9 posts views Thread by William LaMartin | last post: by
9 posts views Thread by Adrian Parker | last post: by
reply views Thread by theflame83 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.