List user group in my pc

A

ad

I want to List user group in MyPc (the name of my computer)
I use the codes below, but it fail in run time at line 2,
How can I correct it?




DirectoryEntry group = new DirectoryEntry("WinNT://WORKGROUP/MyPC");
object members = group.Invoke("Members",null);
foreach( object member in (IEnumerable) members)
{

DirectoryEntry x = new DirectoryEntry(member);
ddlGroup.Items.Add(x.Name);
}
 
W

Willy Denoyette [MVP]

You have to include the groupname in the path like :
new DirectoryEntry("WinNT://MyPC/GroupName,group");
or:
new DirectoryEntry("WinNT://Workgroup/MyPC/GroupName,group");

Willy.
 
A

ad

Thank for your answer,

I want to list all the user group in my Server.

I have tried the code you give.
It resulted in a error in run time.
 
W

Willy Denoyette [MVP]

What error? Please post the exception message and possibly your code.

Willy.
 

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