How to enumerate all the users in Active Directory

Posted on 2013-01-02
Medium Priority
Last Modified: 2013-01-07
Can any one tell me the command in windows to enumerate all the users in domain?
Question by:Babcy
LVL 18

Assisted Solution

Chris earned 600 total points
ID: 38736324
do you want a list? as you can use powershell to do this easily

get-aduser -filter *

then use >users.csv to push it out to a file

if you want to get this a little less info then you can filter the output
if you can be more specific with what you want to see i can give you the syntax
LVL 23

Assisted Solution

by:Thomas Grassi
Thomas Grassi earned 300 total points
ID: 38736329
Here is a script that will do it


or net user /domain

net user /domain >users.txt

Author Comment

ID: 38736357
I wrote following C# code to enumerate all the employess and it is working fine. Now i want to filter the users by OU name.  Is there a way by which i can filter by OU.

 using (var context = new PrincipalContext(ContextType.Domain, "mydomainname.net"))
                using (var searcher = new PrincipalSearcher(new UserPrincipal(context)))
                    foreach (var result in searcher.FindAll())
                        DirectoryEntry de = result.GetUnderlyingObject() as DirectoryEntry;
                        Console.WriteLine("First Name: " + de.Properties["givenName"].Value);
                        Console.WriteLine("Last Name : " + de.Properties["sn"].Value);
                        Console.WriteLine("SAM account name   : " + de.Properties["samAccountName"].Value);
                        Console.WriteLine("User principal name: " + de.Properties["userPrincipalName"].Value);
Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

LVL 18

Accepted Solution

Chris earned 600 total points
ID: 38736384
yes you should be able to call the filter similar to the powershell filter

$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$objOU = New-Object System.DirectoryServices.DirectoryEntry("LDAP://dc=your,dc=domain")

$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objOU
LVL 57

Assisted Solution

by:Mike Kline
Mike Kline earned 300 total points
ID: 38736461
You can also use the following LDAP Query


You can do that in ADUC or use command line methods like adfind, csvde, powershell, etc.


LVL 18

Assisted Solution

by:Sarang Tinguria
Sarang Tinguria earned 300 total points
ID: 38737096
Chris has a great GUI tool for all theese stuffs

Cjwdev | AD Info - Active Directory Reporting www.cjwdev.co.uk/Software/ADReportingTool/Info.html

AdFind by joe but CLI

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Scripts are great for performing batch jobs against users, however sometimes the GUI is all you need.
Seizing the Operation Master Roles in Windows Server 2016 in case of FSMO holder failure.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

587 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