Solved

Listing Windows UserGroups,etc.

Posted on 2003-11-19
4
230 Views
Last Modified: 2010-04-16
I'm looking for some simple code that allows us to list the Windows user groups against a server.
Ideally this would include things like Administrators, etc.
How can this be done against a given domain ?
Any help would be appreciated.
I'm just starting looking at this and looking for a head start ....
Thanks in advance
Steve
0
Comment
Question by:StevenK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Expert Comment

by:Divinity
ID: 9787865
You could take a look at the System.Management namespace and use it to do WQL queries.
0
 

Author Comment

by:StevenK
ID: 9788013
How do I make use of this ?
I'm in uncharted waters .... :(
Steve
0
 
LVL 2

Accepted Solution

by:
jrberg earned 25 total points
ID: 10121978
Add a reference in your project to System.DirectoryServices and do the following.

using System.DirectoryServices;

static void Main()
{
        // In the LDAP string the DC='s represent Hostname Segments (ex. my.domain.com) replace with yours
        // Replace Domaincontroller with your domaincontrollers name
        string Enterprise = "LDAP://domaincontroller/CN=Users,DC=my,DC=domain,DC=com";
        DirectoryEntry myDirectoryEntry = new DirectoryEntry( Enterprise );
        foreach( DirectoryEntry de in myDirectoryEntry.Children )
        {
           Console.WriteLine( de.Name );
        }
}

Hope this is what your looking for,
Jerry

0
 
LVL 2

Expert Comment

by:jrberg
ID: 10122063
One more thing now that I read the question again

1) If you want all the users on the domain use this LDAP in my last code post
 "LDAP://domaincontroller/CN=Users,DC=my,DC=domain,DC=com";

2) If you want all the groups on the domain use this LDAP in my last code post
 "LDAP://domaincontroller/DC=my,DC=domain,DC=com";

This should give you what you want,
Jerry
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question