473,695 Members | 2,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get account name associated with a running process.

I posted this a short while ago , but I don't think I explained the problem
clearly. Task Manager lists processes running on a local system, including a
"user name" associated with each process (e.g. SYSTEM). My application
needs to check if a particular process is running, and if so get the
associated "owner". I am really trying to determine the security context in
which the process was started. Thanks for any input.

-- Moses
Nov 16 '05 #1
6 21672
Hm. I'm not aware of a way to get the process owner. You can certainly
find the process using the static Process.GetProc esses() or
Process.GetProc essByName() methods, and you can determine the machine it's
running on using the MachineName property of a particular Process instance.
From there, I suppose you'd have to have access to the running machine's
Active Directory and find some way to track down process ownership from
there.

If you don't really need to know who the owner is, but just whether YOU own
it or not, you can perhaps find some non-destructive method call against a
Process instance that is disallowed for non-owners, and execute it in a try
block. I know that Kill() and Close() require that you have ownership, but
obviously those wouldn't be methods you'd call to test if you have
ownership. Maybe an attempt to read the Threads collection or something
like that.

Just some random ideas that might suggest an avenue of exporation for you.

--Bob

"Moses M" <Mm*****@msn.co m> wrote in message
news:et******** ******@TK2MSFTN GP11.phx.gbl...
I posted this a short while ago , but I don't think I explained the problem clearly. Task Manager lists processes running on a local system, including a "user name" associated with each process (e.g. SYSTEM). My application
needs to check if a particular process is running, and if so get the
associated "owner". I am really trying to determine the security context in which the process was started. Thanks for any input.

-- Moses

Nov 16 '05 #2
Thanks Bob. I will keep poking around. A friend suggested I use
OpenProcessToke n() which looks to me like "backslidin g" into unamaged code!
-- Moses
"Bob Grommes" <bo*@bobgrommes .com> wrote in message
news:eC******** ******@TK2MSFTN GP10.phx.gbl...
Hm. I'm not aware of a way to get the process owner. You can certainly
find the process using the static Process.GetProc esses() or
Process.GetProc essByName() methods, and you can determine the machine it's
running on using the MachineName property of a particular Process instance. From there, I suppose you'd have to have access to the running machine's
Active Directory and find some way to track down process ownership from
there.

If you don't really need to know who the owner is, but just whether YOU own it or not, you can perhaps find some non-destructive method call against a
Process instance that is disallowed for non-owners, and execute it in a try block. I know that Kill() and Close() require that you have ownership, but obviously those wouldn't be methods you'd call to test if you have
ownership. Maybe an attempt to read the Threads collection or something
like that.

Just some random ideas that might suggest an avenue of exporation for you.

--Bob

"Moses M" <Mm*****@msn.co m> wrote in message
news:et******** ******@TK2MSFTN GP11.phx.gbl...
I posted this a short while ago , but I don't think I explained the problem
clearly. Task Manager lists processes running on a local system,

including a
"user name" associated with each process (e.g. SYSTEM). My application
needs to check if a particular process is running, and if so get the
associated "owner". I am really trying to determine the security context

in
which the process was started. Thanks for any input.

-- Moses


Nov 16 '05 #3
Don't feel guilty; sometimes a little backsliding is just what the doctor
ordered.

P/Invoke and COM Interop are designed, in part, to allow you to get on with
your work even in those areas that .NET doesn't have a managed interface
for. For example, the CLR has virtually no implementation for multimedia
APIs, so you have to resort to P/Invoke to do a simple console beep.

If the truth were known, a lot of the CLR methods are just fig leaves over
P/Invoke calls anyway. How do you think they implement file I/O?

--Bob

"Moses M" <Mm*****@msn.co m> wrote in message
news:OH******** ******@TK2MSFTN GP12.phx.gbl...
Thanks Bob. I will keep poking around. A friend suggested I use
OpenProcessToke n() which looks to me like "backslidin g" into unamaged code! -- Moses
"Bob Grommes" <bo*@bobgrommes .com> wrote in message
news:eC******** ******@TK2MSFTN GP10.phx.gbl...
Hm. I'm not aware of a way to get the process owner. You can certainly
find the process using the static Process.GetProc esses() or
Process.GetProc essByName() methods, and you can determine the machine it's running on using the MachineName property of a particular Process

instance.
From there, I suppose you'd have to have access to the running machine's
Active Directory and find some way to track down process ownership from
there.

If you don't really need to know who the owner is, but just whether YOU

own
it or not, you can perhaps find some non-destructive method call against a Process instance that is disallowed for non-owners, and execute it in a

try
block. I know that Kill() and Close() require that you have ownership,

but
obviously those wouldn't be methods you'd call to test if you have
ownership. Maybe an attempt to read the Threads collection or something
like that.

Just some random ideas that might suggest an avenue of exporation for you.
--Bob

Nov 16 '05 #4
Hi Moses:

You are on the right track. See some sample C# code here:

http://www.sellsbrothers.com/askthew...curityprin.htm

--
Scott
http://www.OdeToCode.com

On Wed, 23 Jun 2004 15:53:23 -0600, "Moses M" <Mm*****@msn.co m> wrote:
Thanks Bob. I will keep poking around. A friend suggested I use
OpenProcessTok en() which looks to me like "backslidin g" into unamaged code!
-- Moses


Nov 16 '05 #5
Thanks guys for all the input. I got OpenProcessToke n() to work OK for a
local system, but it throws an exception for remote systems (says "Feature
is not supported for remote machines"). Severe limitation for my needs.
Grateful for any more suggestions. Meanwhile I will keep searching among the
thorns and thistles!

-- Moses

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:53******** *************** *********@4ax.c om...
Hi Moses:

You are on the right track. See some sample C# code here:

http://www.sellsbrothers.com/askthew...curityprin.htm
--
Scott
http://www.OdeToCode.com

On Wed, 23 Jun 2004 15:53:23 -0600, "Moses M" <Mm*****@msn.co m> wrote:
Thanks Bob. I will keep poking around. A friend suggested I use
OpenProcessTok en() which looks to me like "backslidin g" into unamaged code!-- Moses

Nov 16 '05 #6
Use System.Manageme nt and the Win32_Process class.
Here's a sample...

using System;
using System.Manageme nt;
using System.Diagnost ics;
class App {
public static void Main() {
GetProcessInfo( Process.GetCurr entProcess().Ha ndle.ToInt32()) ;
}

static void GetProcessInfo( int handle)
{
using(Managemen tObject proc = new
ManagementObjec t("Win32_Proces s.Handle='" + handle.ToString () + "'"))
{
proc.Get();
string[] s = new String[2];
//Invoke the method and populate the array with the user name and domain
proc.InvokeMeth od("GetOwner",( object[])s);
Console.WriteLi ne("User: " + s[1]+ "\\" + s[0]);
}
}
}

Willy.

"Moses M" <Mm*****@msn.co m> wrote in message
news:et******** ******@TK2MSFTN GP11.phx.gbl...
I posted this a short while ago , but I don't think I explained the problem
clearly. Task Manager lists processes running on a local system, including
a
"user name" associated with each process (e.g. SYSTEM). My application
needs to check if a particular process is running, and if so get the
associated "owner". I am really trying to determine the security context
in
which the process was started. Thanks for any input.

-- Moses

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
293
by: Rod Kestler | last post by:
After applying the KB Automatic Update #833987 (JPEG Security Issue), our development server suddenly will not allow any IIS 6.0 App Pool running with identity set to ASPNET to run. The Event Viewer shows the following trace from the Application Log: Event Type: Warning Event Source: W3SVC Event Category: None Event ID: 1057
2
3781
by: Moses M | last post by:
I need to get the the user name associated with a running process (Listed as "UserName" in Task Manager Window). The Process Class doesn't seem to provide a direct way for doing this! Thanks -- Moses
3
5367
by: | last post by:
This question references to KB articles: http://support.microsoft.com/default.aspx?scid=kb;EN-US;315158 http://support.microsoft.com/default.aspx?scid=kb;EN-US;317012 I'm running Advanced Server 2000 as a domain controller with IIS 5 (I know I shouldn't be doing this - just a test machine). I am using the default ASP.NET (v1.1) machine.config file..... <processModel..... userName="machine" password="AutoGenerate"..... />
7
1660
by: M. Simioni | last post by:
Hi, i'm always auditing ASPNET's account accesses on my webserver, a WIN2K_SP4 + IIS5 + SQLServer2K_SP3a machine. Nearly all the applications work correctly, but i constantly find a message in the event viewer under the protection log, that says: --------------------------------------- Apertura oggetto: Server oggetto: Security Tipo oggetto: File
0
2307
by: CESAR DE LA TORRE [MVP] | last post by:
I am using WSE 3.0 with Visual Studio 2005, specifically I'm using Kerberos authentication and passing Kerberos ticket from Presentation Tier (VSTO.2005 client) to Server Tier through our Web Services (based on WSE 3.0). Having our WSE 3.0-WebService over Windows Server 2003, everything works great, but, over Windows XP, I have a problem (which is documented in WSE 3.0 help) but its workaround does not work properly (at least with my...
7
6757
by: Billy Angers | last post by:
My server is running under Windows SBS 2003. I've deleted some directories that was containing Outlook Web Access files, it was done few months ago by mistake. Now I want to use OWA for some distant users. So, I tried the procedure on the MS website: http://support.microsoft.com/?scid=kb%3Ben-us%3B883380&x=13&y=19 I've done all of the Method 1, but the files have not been re-created, and I get this Event: Event ID: 1047 Metabase Update...
0
3232
by: robpimentel | last post by:
Hi, I've been using DB2 for about 1 week, so please bear with me. DB2 Connect Enterprise Edition v8.1 FixPack 5 Windows Server 2003 Standard Edition SP1 Here is an error that continues to appear on our domain controllers (Security event log): Event Type: Failure Audit Event Source: Security
6
6389
by: tsmojver | last post by:
Does anyone know how to retreive the logon account username for a particular windows service? Or the current user that is running this service as a process. C# is the prefered language of choice. Apparently, the managed classes don't seem to offer this easily (and for good reason). However, I would think there is a way to do this with an unmanaged call, but not sure where to start. Any help is greatly appreciated, Thanks.
0
8647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8585
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9004
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8864
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4351
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3024
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2288
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.