Solved

Need a VB Script to List all Groups and the OU they are in

Posted on 2004-10-18
5
865 Views
Last Modified: 2012-06-27
Hi,

I want to write a VBS script to get a listing of all Groups in the domain along with the OU that they belong to.

I know how to get the Group.Name, how can I a get a listing of all the information that would be available under that object?

Thanks
0
Comment
Question by:praflik
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 250 total points
ID: 12342711
Here you go.  The VBScript below will loop through all the OUs in the path specified and print out the names of the groups and the OU they were found in.  All you need to do is edit the first line and put in your LDAP path.  The script echos the information out so unless you want to have to keep hitting Return I suggest you run it with Cscript instead of Wscript.


---- BEGIN SCRIPT ----
ProcessOU "LDAP://server.company.com/dc=company,dc=com"
Wscript.Quit

Private Sub ProcessOU(strADSPath)
    Dim objAD
    Dim objOU
    Set objAD = GetObject(strADSPath)
    objAD.Filter = Array("OrganizationalUnit")
    SearchForGroups objAD.ADsPath, objAD.Name
    For Each objOU In objAD
        ProcessOU objOU.ADsPath
    Next
End Sub

Private Sub SearchForGroups(strADSPath, strOUName)
    Dim objOU
    Dim objGroup
    Set objOU = GetObject(strADSPath)
    objOU.Filter = Array("group")
    For Each objGroup In objOU
      Wscript.Echo "Group=" & Mid(objGroup.Name,4) & Space(50 - Len(Mid(objGroup.Name,4))) & strOUName
    Next
End Sub
0
 
LVL 76

Expert Comment

by:David Lee
ID: 12561214
Accept BlueDevilFan http:#12342711
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

947 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now