473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Management Query

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...32_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
Nov 16 '05 #1
2 2733
Your code with "select * from win32_account where SIDType=1" as the
query works nicely on my box.

Regards,
Joakim

Alexander Wehrli wrote:
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...32_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

Nov 16 '05 #2
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" wrote:
Your code with "select * from win32_account where SIDType=1" as the
query works nicely on my box.

Regards,
Joakim

Alexander Wehrli wrote:
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...32_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

Nov 16 '05 #3

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

Similar topics

2
by: Paul Gronka | last post by:
I've got a VB.NET windows application (written in VS .NET 2003) that makes a call to WMI for retrieving the MAC Address from the client's PC. It works on 4 out of the 5 PC's tested so far. All...
0
by: Ben Reese | last post by:
Kind people on this discussion group have previously helped me to dynamically identify CD rom drives etc at runtime using objects in System.management +++++++++++++++++++++++++++++++++++++++ Dim...
0
by: Justin M via .NET 247 | last post by:
Hi, I'm trying to do asynchronous consumption of WMI events using System.Management. Basically I want to monitor the connection status of Win32_NetworkAdapter. (i.e recieve events when it...
0
by: Scupper | last post by:
I am using the System.Management namespace for the first time and I cannot get the ManagementObject.SetPropertyValue method to work properly. I am trying to change the ServerName and ShareName...
0
by: Katsaros Kwn/nos | last post by:
Hi! I have some problems with the SPI memory management (at least I think this is the problem). What I'm trying to do is to get the Query related to a select statement, alter it and produce a...
0
by: Gancy | last post by:
Hello, The code below enumerates all products installed on any given machine. Through System.Management i can also find WMI methods that could be exected. But i have not worked on WMI and...
2
by: Lamis | last post by:
Hi, I need urgent help, this is my code to rename my hostName: (MY computer is not member of domain) string compName = System.Windows.Forms.SystemInformation.ComputerName.ToString();...
1
by: ShrimpBoy | last post by:
Hi! I'm trying to erase SMS_Collection Rules using VB.NET 2003... I did that with WbemScripting, but now I need to do it with System.Management... My problem is that with System.Management...
3
by: cmay | last post by:
The question is: Which one of the following is NOT a valid state management tool? And the possible answers are: 1. Hidden Form Fields 2. Cookies
12
by: not_a_commie | last post by:
Is using System.Management in general a faux pas? It seems, after some web searching, that there is a fair amount of resistance to it because of speed and portability. I need to know how many...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...
0
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...

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.