Get All Domain Users?

  • Thread starter Thread starter xenophon
  • Start date Start date
X

xenophon

I am working with a Windows 2003 native domain, users are in Domain
Local Groups, Global Groups, and Local Groups. Users are not all
lumped into the "users container".

Is there a way to query a DC for all users, regardless of their
container/location? In the NT days of the flat SAM, this would be
relatively easy.

I am currently using ADSI and LDAP queries with C# to get things in
individual containers, but I need a "global get".

Thanks.
 
Hi Xenophon,

You can take a look at the link below.

Querying Microsoft Active Directory Using Microsoft .NET Framework Library
http://www.codeproject.com/dotnet/QueryADwithDotNet.asp

All Users
The last query I want to discuss in this article is meant to return a list
of all the AD domain users.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
I am working with a Windows 2003 native domain, users are in Domain
Local Groups, Global Groups, and Local Groups. Users are not all
lumped into the "users container".
Is there a way to query a DC for all users, regardless of their
container/location?

Sure - have a look at the DirectorySearcher class in
System.DirectoryServices.

What you need to do is specify the domain level as your search root
(LDAP://dc=yourcompany,dc=com), a filter to pick the users, and then
call the .FindAll() method to get all users.

If you expect to get back more than 1000-1500 users, you'll also need
to set the .PageSize property of the DirectorySearcher to a value
other than zero, e.g. 1000, to allow AD to do "paged searches" and
return all users.

HTH
Marc
 
Back
Top