Re: Get real logon user from windows services
From: Valery Pryamikov (Valery_at_nospam.harper.no)
Date: 07/18/04
- Previous message: Jonathan Pierce: "Re: Obfuscator and Decompiler"
- In reply to: Bui Pham Minh Tri: "Get real logon user from windows services"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Sun, 18 Jul 2004 16:51:33 +0200
Hi,
The problem is that it could be many currently logged on users (if your
server has one or more terminal sessions open) or it could be no currently
logged on users.
Windows services are alwais started in session 0 (global namespace).
if terminal client session is open against your server - they will be
running in other sessions 1,2,...x.
If you are interesting to get logged on user identities, you can try to
enumeration shell processes and get this information from shell process
token. You can check my old CreateProcessAsUser sample
http://www.harper.no/valery/oldsite/CreateProcessAsUser.zip
where I do exatly this - check wich process is registered to run as shell,
enumerate processes (session 0 only), find shell process and retrieve
process token.
-Valery.
http://www.haprer.no/valery
"Bui Pham Minh Tri" <minhtri@pyramid-consulting.com> wrote in message
news:%232%23%23AqIbEHA.2340@TK2MSFTNGP09.phx.gbl...
I have written a windows service, but when I use
System.Security.Principal.WindowsIdentity.GetCurrent().Name to get the
current logon user, it returned NT AUTHOURITY\SYSTEM. How can I get the name
of current logon user, for example DOMAIN\user?
Thanks for any solutions.
- Previous message: Jonathan Pierce: "Re: Obfuscator and Decompiler"
- In reply to: Bui Pham Minh Tri: "Get real logon user from windows services"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|