Solved

Listing Windows UserGroups,etc.

Posted on 2003-11-19
4
223 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
  • 2
4 Comments
 
LVL 5

Expert Comment

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

Author Comment

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

Accepted Solution

by:
jrberg earned 25 total points
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now