Finding Logged on user from a service

Finding Logged on user from a service

am 01.10.2007 05:04:02 von bill

Hello,

I have a windows service running under the local system account. I want to
be able to impersonate the current user logged onto windows. How can I
determine the current user. APIs all seem to return the name of the user
running the current process. ".\LocalSystem" which is not what I require.

--
Bill

Re: Finding Logged on user from a service

am 03.10.2007 15:09:15 von Stephan Brenner

I do not know a .NET Framework method to get the logged on user. What
should work is to DllImport the method GetUserName from advapi32.dll and
use that.

Bill wrote:
> Hello,
>
> I have a windows service running under the local system account. I want to
> be able to impersonate the current user logged onto windows. How can I
> determine the current user. APIs all seem to return the name of the user
> running the current process. ".\LocalSystem" which is not what I require.
>