How to list ALL Users

  • Thread starter Thread starter daveM
  • Start date Start date
D

daveM

I am having one DC in a second site failing after upgrade from 2000 to 2003.
The error msg apparently relates to a "bad" user name such that the "server
is not operational". I need a tool or command that I can run on the other
dc, the PDO of the domain, and list ALL user objects in AD, regardless of
their OU or site.

dave Admin
 
daveM said:
I am having one DC in a second site failing after upgrade from 2000 to 2003.
The error msg apparently relates to a "bad" user name such that the "server
is not operational". I need a tool or command that I can run on the other
dc, the PDO of the domain, and list ALL user objects in AD, regardless of
their OU or site.

dave Admin

Microsoft already provides the dsquery tool which lets you query the directory
for all users or computers in th directory regardless of what OU they are in.
 
Additionally, if you were into scripting you could make use of ADSI to get
this. You might want to filter this using sAMAccountType=805306368 as this
will give you only the user account objects ( all of them..... ).

The following from Robbie Allen's cookbook might be of help:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


' This VBScript code finds all user accounts in a domain.

' ---------------------------------------------------------------
' Provided as a web-only addition for the book:
' "Active Directory Cookbook" by Robbie Allen
' Publisher: O'Reilly and Associates
' ISBN: 0-596-00466-4
' Book web site: http://rallenhome.com/books/adcookbook/code.html
' ---------------------------------------------------------------

' ------ SCRIPT CONFIGURATION ------
strDomainDN = "<DomainDN>" ' e.g. dc=rallencorp,dc=com
' ------ END CONFIGURATION ---------

strBase = "<LDAP://" & strDomainDN & ">;"
' To search the whole forest using the global catalog, uncomment the
following line:
' strBase = "<GC://" & strDomainDN & ">;"

strFilter = "(&(objectclass=user)(objectcategory=person));"
strAttrs = "name;"
strScope = "subtree"

set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"
set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope)
objRS.MoveFirst
while Not objRS.EOF
Wscript.Echo objRS.Fields(0).Value
objRS.MoveNext
wend++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Again,
you might want to replace the strFilter that he uses with the suggestion
that I have made....just a thought.


--
Cary W. Shultz
Roanoke, VA 24012
Microsoft Active Directory MVP

http://www.activedirectory-win2000.com
http://www.grouppolicy-win2000.com
 
Back
Top