Windows service: Get username when user log on

前端 未结 3 560
傲寒
傲寒 2021-01-28 02:02

my windows service should save the name of the user, which logon/logoff at the moment. The following code works for me but didn\'t save the username:

protected o         


        
3条回答
  •  情歌与酒
    2021-01-28 02:18

    You could try:

    System.Security.Principal.WindowsIdentity.GetCurrent();
    

    another option, see: Getting logged-on username from a service

提交回复
热议问题