Windows username

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

Is it possible to get the currently logged in username in windows 2000/xp?

Thanks

Regards
 
Yes, you can obtain the current identity using this:

WindowsIdentity identity = WindowsIdentity.GetCurrent();
string userName = identity.Name;
 
* "John said:
Is it possible to get the currently logged in username in windows 2000/xp?

You can use 'Environment.UserName' to get the name of the user who
started the thread.
 
Hi John, the user in which your application context is running can be gotten
by Environment.Username, but if you want the *real* user, it will require a
bit of coding.

Generally, however, Environment.UserName is the best way to go, if you're
sure your app is being run by a user.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
 
Back
Top