Query the Contents of an Container and/or Security Group in Active Directory

Posted on 2003-02-26
Medium Priority
Last Modified: 2010-05-01
With Visual Basic I would like to query the contens of an container and/or the users assigned to a global security group from active directory.
Question by:FPhillips
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

Accepted Solution

Gunsen earned 800 total points
ID: 8031925
Add "Active DS Type Library" below Project-References.

To enumerate container:
  Dim c As IADsContainer
  Set c = GetObject("LDAP://ou=Groups,dc=company,dc=net")
  For Each obj In c
    Debug.Print obj.Name

To list group members:
  Dim group As IADsGroup
  Set group = GetObject("LDAP://cn=group1,ou=Groups,dc=company,dc=net")
  For Each User In group.Members
    Debug.Print User.Name

Expert Comment

ID: 8901058
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
LVL 49

Expert Comment

ID: 8983477
Moderator, my recommended disposition is:

    Accept Gunsen's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer

Expert Comment

ID: 13968481
Hi there, I just wanted to add an additional thank you to Gunsen for this code.  It's proving invaluable in the development of the software applications I'm writing at present.  Using it to get lists of groups in AD, of Users in a specific group and then using these lists to validate users who log into our systems. Outstanding, thank you! :)



Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

801 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