Retrieve current user in Windows

  • Thread starter Thread starter Sylvain Larin
  • Start date Start date
S

Sylvain Larin

I want to give the access right to my application based on who is
currently logued in Windows. How can I get the current username from
Windows?

TIA
 
Hi

AppDomain myDomain = Thread.GetDomain();

myDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

WindowsPrincipal mWinPrin mWinPrin =
(WindowsPrincipal)Thread.CurrentPrincipal ;

This also allows you to check if the user belongs to certain groups etc,



Henk
 
Back
Top