Management Query

G

Guest

Hi all,

I wanted to design a wmi query that returns me a list of all "real" user
accounts defined on the local machine. As you may know, the accounts are
defined in win32_account. The field SIDType indicates what kind of account it
is(user, group, Domain, etc.). (On MSDN:
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_account.asp)

This results in the following query --> "select * from win32_account where
SIDType=1"

This query doesn't bring me any result! But if I query this table with a
username (e.g. select * from win32_account where Name='alw') I get my own
account and my SIDType is 1!

My Code (simple):
sbyte b = SByte.Parse("1");
Console.WriteLine(b);
ManagementObjectSearcher searcher = new
ManagementObjectSearcher("select * from Win32_Account where SIDType="+b);
foreach (ManagementObject service in searcher.Get())
{
Console.WriteLine("User Caption = " + service["Name"]);
}

Can anybody help me?

Regards Alexander
 
J

Joakim Karlsson

Your code with "select * from win32_account where SIDType=1" as the
query works nicely on my box.

Regards,
Joakim
 
G

Guest

Hi,

Is it possible that this query assumes that I am local administrator? I
can't imagine because other queries work fine... Any ideas?

Regards Alexander

Joakim Karlsson said:
Your code with "select * from win32_account where SIDType=1" as the
query works nicely on my box.

Regards,
Joakim

Alexander said:
Hi all,

I wanted to design a wmi query that returns me a list of all "real" user
accounts defined on the local machine. As you may know, the accounts are
defined in win32_account. The field SIDType indicates what kind of account it
is(user, group, Domain, etc.). (On MSDN:
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_account.asp)

This results in the following query --> "select * from win32_account where
SIDType=1"

This query doesn't bring me any result! But if I query this table with a
username (e.g. select * from win32_account where Name='alw') I get my own
account and my SIDType is 1!

My Code (simple):
sbyte b = SByte.Parse("1");
Console.WriteLine(b);
ManagementObjectSearcher searcher = new
ManagementObjectSearcher("select * from Win32_Account where SIDType="+b);
foreach (ManagementObject service in searcher.Get())
{
Console.WriteLine("User Caption = " + service["Name"]);
}

Can anybody help me?

Regards Alexander
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top