- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsI am trying to build a group access report. You can assume that the starting group ADSI path is passed into a ASP page. I need to take that AD group, look at all the nested users and groups and build a report with all users and the containers (nested groups) that they have access to. So I want a complete view of every user that has access to the group (like the adminstrators group) listed on one report and not have to manually look in each nested group to see who is there. For the example below: Domain2\Enterprise Admins and Domain1\Domain Admins are nested in Domain1\Administrators.
UserName Fullname Description Group Name
-------- -------- ----------- ---------------
user1 Jones,Bob CA User Domain1\Administrators
user2 Hots,Bob NC User Domain1\Domain Admins
user3 Tots,Bob SC User Domain1\Domain Admins
user4 Otts,Deb US Field Domain2\Enterprise Admins
4 Users found
So a group can potentially have multiple nestings (like Domain2\Enterprise Admins could have groups nested in it too) and I need the logic to be able to go as deep as it needs to back out all the users from each nested group. That is what makes this one so much fun :) This can be done in VB or VBscript. Would like it sorted by the Group Name columns if possible and show the same user again and again if they are members of multiple nested groups. Should be able to handle hundreds of entries, but I won't be running it on the Domain Users group of course.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: TheMCSEPosted on 2005-05-03 at 17:47:55ID: 13922973
If you're looking for additional ADSI scripting, you may receive a faster response by posting here:
e.com/Prog ramming/ Pr ogramming_ Languages/ Visual_Bas ic/
strators"
ath, 9), "/", "\") & DELIMITER & objMember.FullName & DELIMITER & objMember.Description & DELIMITER & strGroupName ath, 9), "/", "\") ath, 9), "/", "\") & DELIMITER & DELIMITER & DELIMITER & DELIMITER & strGroupName
pting.File SystemObje ct") UT_FILE_NA ME) ---------- -------" & vbCrLf & "UserName" & DELIMITER & "FullName" & DELIMITER & "Description" & DELIMITER & "Group Name" & vbCrLf & "------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -------"
http://www.experts-exchang
The code below should provide the information you desire. The constants near the top of the script should be modified to reflect the appropriate values. Running this may be frightening :)
'begin
Option Explicit
On Error Resume Next
Const GROUP_DN = "WinNT://YOURDOMAIN/Admini
Const OUTPUT_FILE_NAME = "Groups.txt"
Const DELIMITER = " "
Dim intCounter, objFileOutput, objFSO, objGroup, objMember, strDomainName
Sub EnumGroups(strDN, strGroupName)
Set objGroup = GetObject(strDN)
For Each objMember In objGroup.Members
Select Case objMember.Class
Case "User"
objFileOutput.WriteLine Replace(Mid(objMember.ADsP
intCounter = intCounter + 1
Case "Group"
EnumGroups objMember.ADsPath, Replace(Mid(objMember.ADsP
Case Else
objFileOutput.WriteLine Replace(Mid(objMember.ADsP
intCounter = intCounter + 1
End Select
Next
End Sub
Set objFSO = WScript.CreateObject("Scri
Set objFileOutput = objFSO.CreateTextFile(OUTP
objFileOutput.WriteLine Replace(Mid(GROUP_DN, 9), "/", "\") & vbCrLf & "-------------------------
EnumGroups GROUP_DN, Replace(Mid(GROUP_DN, 9), "/", "\")
objFileOutput.WriteLine intCounter & " user(s) found"
MsgBox "Completed enumerating users.", vbInformation, "Execution completed"
'end
This creates a delimited file (fields separated by the value you specify in the DELIMITER constant, currently a tab). If you have any questions, please let me know. Good luck!