Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Listing Windows UserGroups,etc.

Posted on 2003-11-19
Medium Priority
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
Question by:StevenK
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

Expert Comment

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

Author Comment

ID: 9788013
How do I make use of this ?
I'm in uncharted waters .... :(

Accepted Solution

jrberg earned 75 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,


Expert Comment

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

2) If you want all the groups on the domain use this LDAP in my last code post

This should give you what you want,

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

610 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