Chris,
I think you might want to re-think what you are trying to do. It is
actually possible to have multiple logon sessions on the computer at the
same time (a process might run another process as a different user, causing
another logon session, for example).
In order to get the information about these logon sessions, your easiest
solution is to go through the System.Management namespace, querying for all
instances of the Win32_LogonSession WMI class. You can find an example here
(watch for line wrap):
http://groups.google.com/groups?hl=e....phx.gbl#link2
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"ChrisB4745" <Ch********@discussions.microsoft.com> wrote in message
news:95**********************************@microsof t.com...
I'm working on a system service application that is supposed to report
various information about the computer it is running on back to a central
server. One of the things I need to know is the username of the person who
is currently logged on to the actual computer. I've tried using Name =
System.Security.Principal.WindowsIdentity.GetCurre nt().Name.ToString(); However, since the service is owned by "System" I get
"NT_AUTHORITY\SYSTEM" as a result. So how do I get the username of the
person who is logged on instead of the name of the owner of the current
process?
Thanks for any help,
Chris