Retrieve current user in Windows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sylvain Larin

    #1

    Retrieve current user in Windows

    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
  • Sean Hederman

    #2
    Re: Retrieve current user in Windows

    System.Environm ent.UserDomainN ame/UserName
    "Sylvain Larin" <slarin@NOSPAM_ gmail.com> wrote in message
    news:OqA%23TYkK FHA.436@TK2MSFT NGP09.phx.gbl.. .[color=blue]
    >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[/color]


    Comment

    • Henk Verhoeven

      #3
      Re: Retrieve current user in Windows

      Hi

      AppDomain myDomain = Thread.GetDomai n();

      myDomain.SetPri ncipalPolicy(Pr incipalPolicy.W indowsPrincipal );

      WindowsPrincipa l mWinPrin mWinPrin =
      (WindowsPrincip al)Thread.Curre ntPrincipal ;

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



      Henk

      "Sylvain Larin" <slarin@NOSPAM_ gmail.com> wrote in message
      news:OqA%23TYkK FHA.436@TK2MSFT NGP09.phx.gbl.. .[color=blue]
      >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[/color]


      Comment

      Working...