Solved

How to enumerate all the users in Active Directory

Posted on 2013-01-02
6
333 Views
Last Modified: 2013-01-07
Can any one tell me the command in windows to enumerate all the users in domain?
0
Comment
Question by:Babcy
[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
6 Comments
 
LVL 18

Assisted Solution

by:irweazelwallis
irweazelwallis earned 200 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
0
 
LVL 23

Assisted Solution

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

http://www.windowsadminscripts.com/coding/networking/adusers/

or net user /domain

net user /domain >users.txt
0
 

Author Comment

by:Babcy
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);
                        Console.WriteLine();
                    }
                }
            }
            Console.ReadLine();
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 18

Accepted Solution

by:
irweazelwallis earned 200 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
0
 
LVL 57

Assisted Solution

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

(&(objetecategory=person)(objectclass=user))

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

Thanks

Mike
0
 
LVL 18

Assisted Solution

by:Sarang Tinguria
Sarang Tinguria earned 100 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
Or

AdFind by joe but CLI
www.joeware.net/freetools/tools/adfind/index.htm
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

738 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