Filter based enumeration (Visual Basic)

This code can be found in Chapter 4 of Managing Enterprise Active Directory Services

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the Visual Basic code from this site.

'# ------------------------------------------------------------------
'# From the book "Managing Enterprise Active Directory Services"
'# ISBN: 0-672-32125-4
'# Copyright (C) 2002 by Addison-Wesley
'# Script by Robbie Allen
'# -------------------------------------------------------------------
Dim Container as IADsContainer
Set Namespaces = GetObject("LDAP://cn=Users,dc=xyz,dc=com")
'If you perform an enumeration without a filter, you return objects of all classes - users, groups, etc.
'Adding a Filter, you can tailor the result set to objects of the specified class(es):
Container.Filter = Array("User")
For Each User in Container
         Debug.Print User.ADsPath
Next

This code has been viewed 1463 times.

New from the creators of TechTasks.com: StatSheet.com