473,321 Members | 1,622 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,321 software developers and data experts.

Win32_UserAccount

Does anyone has an example of how to use Win32_UserAccount class ?

I looked in MSDN but there is only a VB example

Hrcko
Nov 17 '05 #1
1 6475

"Hrvoje Voda" <hr*********@luatech.com> wrote in message
news:d7**********@ss405.t-com.hr...
Does anyone has an example of how to use Win32_UserAccount class ?

I looked in MSDN but there is only a VB example

Hrcko


The description and samples in MSDN should be sufficient to use all possible
WMI classes, just make sure you are familiar with the WMI namespace before
you start using the System.Management classes though.
A good way to achieve this is to use the Wbemtest.exe utility that comes
with XP/W2K3 or the WMI studio that comes with the WMI platform SDK.

Anyway, here is a small but complete sample illustrating the use of
win32_useraccount.

using System;
using System.Management;

public class Application{
public static void Main()
{
// Retrieve the SID of the local "administrator" account
string domain = Environment.MachineName;
string sid = GetAccountSid(domain, "administrator");
Console.WriteLine(sid);
}
static string GetAccountSid(string domain, string name)
{
string accountSid = null;
string CIMObject =
String.Format("win32_useraccount.domain='{0}',name ='{1}'", domain, name);
Console.WriteLine(CIMObject);
using(ManagementObject mo = new ManagementObject(CIMObject))
{
mo.Get();
accountSid = mo["SID"].ToString();
}
return accountSid;
}
}

Willy.
Nov 17 '05 #2

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

Similar topics

3
by: Jim Scheffler | last post by:
Hello Group, Could someone point me to an explanation of this statement, Dim Domain As String = Console.ReadLine() Dim UserQuery As String = "SELECT * FROM Win32_UserAccount " & _ "WHERE...
0
by: Wayne Gibson | last post by:
Hi all, Please ignore the other post.. The cat jumped on the machine and sent it before I could stop it!! Was wondering if anybody has expericence this problem.. I am writting an application...
1
by: Bryan | last post by:
How can I get a list of all users currently logged into a Windows Server? My program will be a windows service that has administrative access, so I should have the correct access to do this. ...
5
by: Thom Little | last post by:
Dumb questions 14 and 15 ... 14 How to I access the User Name in C#? 15 How do I access the Organization Name in C#? -- -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd. --
2
by: Hrvoje Voda | last post by:
How to check if a user is logged into domain ? Hrcko
0
by: Blaz Ziherl | last post by:
I am using the following code to get the list of all groups that the user "blaz" on the domain "BCOMAPQ" belongs to: Dim myDomain As String = "BCOMPAQ" Dim theUser As String = "blaz" Dim Query...
3
by: LamSoft | last post by:
I have the access denied on my ASP.NET C# program while deploy my project from my PC (WinXP) to Server 2003 The program works fine on my PC but get access denied on Server 2003. However the...
11
by: nethajireddy | last post by:
Hi, I want to find users using SID, how it is possible, can anyone help me out, please waiting for ur reply...
2
by: emooo | last post by:
Hello I try to list all windows user using this code but it throws exception of invalid query , I am using win vista. the code: try { SelectQuery sQuery...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.