We help IT Professionals succeed at work.
Get Started

Efficient enumeration of domain users

LanWorks asked
Last Modified: 2013-12-25
I am trying to enumerate the users (and some key information) from an Active directory that has 3000+ users.  The biggest limitation is that it must run as a regular domain user (not a domain admin).  I have tried 4 difference approaches:

approach 1) This only gives me for the local users ( no domain user ... so I assume it must be run as a domain admin??)
Set objComputer = GetObject("WinNT://" & strDomain)
objComputer.Filter = Array("User")
For Each objUser In objComputer

approach 2) This seems to work but is very very slow
lRet = NetUserEnum(bytServerName(0), 10, FILTER_NORMAL_ACCOUNT, lptrStrBuffer, 1, lUsersRead, lTotalUsers, lHnd)

approach 3) This seems to work very fast but I do not get users.  Just what looks like a lot of DNS entrys with objectClass as null (so I assume my syntax is wrong?)
    Set conn = New ADODB.Connection
    conn.Provider = "ADSDSOObject"
    conn.Open "ADs Provider"
    Set rs = conn.Execute("<LDAP://SERV001>;(objectClass=*);ADsPath,objectClass,cn;subtree")

approach 4) This seems fast but I only get info for 1 user at a time.  And I have to know what the user is (no good since I am trying to get a list of all users)
usr = GetUserNetworkInfo(bServername(), bUsername())

I will be needing to sync this to another application every 15 minutes so I need a very efficient method  (this as part of a VB6 Activex.Dll project)

Watch Question
Top Expert 2010
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE