Wednesday, August 1, 2007

How to Find the Available Users and Groups in a Local Machine using C#.Net

private void button1_Click(object sender, System.EventArgs e)
{
using(DirectoryEntry root = new DirectoryEntry("WinNT://"+ Environment.MachineName))
{
foreach (DirectoryEntry child in root.Children)
{
if (child.SchemaClassName == "User")
{
listBox1.Items.Add(child.Name);
}
}
}
}



private void button2_Click(object sender, System.EventArgs e)
{
using(DirectoryEntry root = new DirectoryEntry("WinNT://"+ Environment.MachineName))
{
foreach (DirectoryEntry child in root.Children)
{
if (child.SchemaClassName == "Group")
{
listBox2.Items.Add(child.Name);
}
}
}
}

No comments:

 
Feedback Form