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

x
?
Solved

Listing Windows UserGroups,etc.

Posted on 2003-11-19
4
Medium Priority
?
232 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 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,
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

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