473,563 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.WriteLi ne(b);
ManagementObjec tSearcher searcher = new
ManagementObjec tSearcher("sele ct * from Win32_Account where SIDType="+b);
foreach (ManagementObje ct service in searcher.Get())
{
Console.WriteLi ne("User Caption = " + service["Name"]);
}

Can anybody help me?

Regards Alexander
Nov 16 '05 #1
2 2742
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.WriteLi ne(b);
ManagementObjec tSearcher searcher = new
ManagementObjec tSearcher("sele ct * from Win32_Account where SIDType="+b);
foreach (ManagementObje ct service in searcher.Get())
{
Console.WriteLi ne("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.WriteLi ne(b);
ManagementObjec tSearcher searcher = new
ManagementObjec tSearcher("sele ct * from Win32_Account where SIDType="+b);
foreach (ManagementObje ct service in searcher.Get())
{
Console.WriteLi ne("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
14012
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 the workstations are DELLs running XP SP1a with the 1.1 .NET Framework. The following line of code generates an exception on the one PC: Dim oMac...
0
1735
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 query As New System.Management.ManagementObjectSearcher("SELECT * From Win32_LogicalDisk") Dim queryCollection As...
0
1095
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 connects, disconnects) I tried implementing and changing this code from msdn: ...
0
3920
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 of a printer, to facilitate changing the print server of workstations remotely in the event of a print server failure. Thanks in advance for any...
0
1225
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 new SPI_plan that will execute. To do so, I retrieve the query from the _SPI_plan->qtlist, alter it (seems OK in nodeToString) and then use some...
0
2289
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 System.Management before, i need to know how to execute the those mehtods ConnectionOptions options = new ConnectionOptions(); options.Authority =...
2
5474
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(); WqlObjectQuery query = new WqlObjectQuery("SELECT * FROM Win32_ComputerSystem"); ManagementObjectSearcher search = new ManagementObjectSearcher(query);
1
6299
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 I cannot get directly the item without enumerating a bunch of them (as I know)...
3
12498
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
2380
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 CPU sockets there are. I'm using System.Management to do this. It takes about two seconds to do this. (Which, yes, is full-on crap for speed.) But...
0
7659
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...
0
7580
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...
0
7882
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8103
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...
0
7945
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3618
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2079
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
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.