Re: UserName of a process



Nicholas,

I am trying to follow the steps you have mentioned. What do i have to import
in order to be able to use the methods like OpenProcessToken,
GetTokenInformation, etc...? I will be searching online as i wait for your
reply.

--
Thanks
Prisy


"Nicholas Paldino [.NET/C# MVP]" wrote:

> Prisy,
>
> In order to do that, you would have to get a handle to the process you
> want to get the username for first. Assuming you have that, you will have
> to do a bit of P/Invoke calls to get it.
>
> First, you would call OpenProcessToken. Once you have the token for the
> process, you would call GetTokenInformation passing the value TokenUser for
> the TokenInformationClass parameter. This will return a TOKEN_USER
> structure which contains the SID for the user that the process was launched
> under. The only field that the TOKEN_USER structure has is of type
> SID_AND_ATTRIBUTES, which has two fields, Sid and Attributes. The Sid field
> is the pointer to the SID. With that, you can call the LookupAccountSid
> function, passing the pointer to the SID and getting the domain and user
> that the process was started under.
>
> You should be able to find most of the definitions for these functions
> at http://www.pinvoke.net. If they are not there, post back, and we can
> help you with the definitions.
>
> Hope this helps.
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> "Prisy" <Prisy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:F91E3EDA-9A5B-4659-9C49-025DFDE3231D@xxxxxxxxxxxxxxxx
> > In asp.net(C#) we can get the Process Name of a process using the
> > following
> > code:
> >
> > System.Diagnostics.Process item;
> > item.ProcessName.ToString();
> >
> > Is there a way to get the User Name of a process?
> > --
> > Thanks
> > Prisy
>
>
>
.



Relevant Pages

  • Re: UserName of a process
    ... want to get the username for first. ... SID_AND_ATTRIBUTES, which has two fields, Sid and Attributes. ... is the pointer to the SID. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: C# prototype of C: void**
    ... private static extern int imgSnap(int sid, ref IntPtr bufAddr); ... have a pointer to a pointer, you need to pass it by ref. ... How do I call this C# method (rval is uint, sid is int)? ... > "bufAddr" exists allready, it must not be allocated, and I don't want ...
    (microsoft.public.dotnet.languages.csharp)
  • Mouse Pointer
    ... When I switch to the console ctrl-alt-f1 and go back to Xwindow ... shows up the Xwindow X pointer on the center of the screen but the ... PD this happens with Sarge and SID too ...
    (Debian-User)
  • How to get a pointer to a SID from an ACE
    ... a pointer to an Access Control Entry and from that gets a pointer to a ... a SidStart field that's used to get a pointer to the SID. ...
    (microsoft.public.win2000.security)
  • How to get a pointer to a SID from an ACE
    ... a pointer to an Access Control Entry and from that gets a pointer to a ... a SidStart field that's used to get a pointer to the SID. ...
    (microsoft.public.win2000.security)