LDAP
Deep Audit: Listing Nested Active Directory Group Members via VBScript | Lazy Admin Blog

Have you ever looked at a “Domain Admins” group and thought it looked suspiciously small? The culprit is usually nesting. Standard AD queries often fail to “recurse,” meaning they show you the subgroup but not the people inside it.
This script, ListGroupMembers_IncludingNested.vbs, uses a recursive function to dive into every sub-group and extract the actual users, ensuring your security audits are 100% accurate.
The Script: How it Works
The script utilizes a Dictionary Object to keep track of groups it has already scanned. This is a critical “Lazy Admin” safety feature—it prevents the script from getting stuck in an infinite loop if two groups are members of each other.
Usage Instructions
- Copy the code below into Notepad.
- Edit the
StrGroupNamevariable to match your target group. - Save the file as
ListGroupMembers.vbs. - Run it from the command prompt using
cscript ListGroupMembers.vbs.
' -- Save as ListGroupMembers_IncludingNested.vbsOption ExplicitDim ObjRootDSE, ObjConn, ObjRS, ObjCustomDim StrDomainName, StrGroupName, StrSQL, StrGroupDN, StrEmptySpaceSet ObjRootDSE = GetObject("LDAP://RootDSE")StrDomainName = Trim(ObjRootDSE.Get("DefaultNamingContext"))' -- Edit the line below with your Group NameStrGroupName = "YourGroupNameHere" StrSQL = "Select ADsPath From 'LDAP://" & StrDomainName & "' Where ObjectCategory = 'Group' AND Name = '" & StrGroupName & "'"Set ObjConn = CreateObject("ADODB.Connection")ObjConn.Provider = "ADsDSOObject": ObjConn.Open "Active Directory Provider"Set ObjRS = ObjConn.Execute(StrSQL)If ObjRS.EOF Then WScript.Echo "Group not found: " & StrGroupNameElse StrGroupDN = Trim(ObjRS.Fields("ADsPath").Value) Set ObjCustom = CreateObject("Scripting.Dictionary") GetAllNestedMembers StrGroupDN, " ", ObjCustomEnd If
Why VBScript in 2026?
While PowerShell is the modern standard, many legacy environments and automated scheduled tasks still rely on VBScript because it requires zero execution policy changes and runs natively on every Windows machine since Server 2000. It is the “Old Reliable” of the AD world.
Key Features of this Script
- Recursive Discovery: It doesn’t just stop at the first layer.
- Class Identification: Clearly marks if a member is a
User,Computer, or anotherGroup. - Loop Protection: Uses the
Scripting.Dictionaryto escape circular nesting traps.
#ActiveDirectory #WindowsServer #CyberSecurity #SysAdmin #ITAudit #VBScript #Automation #LazyAdmin #TechArchive
Master the Forest: Top Active Directory Interview Questions & Answers | Lazy Admin Blog

Part 1: The Logical vs. Physical Structure
Understanding how AD is organized is the first step in mastering the service. Interviewers often look for the distinction between how objects are managed (logical) and how traffic flows (physical).
Logical Components
These define the administrative boundaries and hierarchy:
- Forest: The uppermost boundary. It contains one or more trees that share a common schema and global catalog.
- Tree: A collection of domains that share a contiguous namespace (e.g.,
corp.comanddev.corp.com). - Domain: The primary unit of replication and security. All objects in a domain share a common database (
ntds.dit). - Organizational Unit (OU): Containers used to organize objects within a domain. OUs are primarily used to delegate administration and apply Group Policy.
Physical Components
These define how AD exists on hardware and over the network:
- Domain Controllers (DC): The servers that host the AD database and handle authentication.
- Sites: A grouping of IP subnets connected by high-speed links. Sites are used to control replication traffic and ensure users log on to a local DC rather than one across a slow WAN link.
Part 2: The Core “Under the Hood” Mechanics
The Active Directory Database
The database is stored in %systemroot%\ntds as ntds.dit. Key files include:
- edb.log: Transaction logs (changes are written here first).
- res1.log / res2.log: Reserve logs to ensure the system can write to disk if space runs out.
- edb.chk: The checkpoint file that tracks which transactions have been committed to the database.
The Global Catalog (GC)
The GC is a partial, read-only replica of every object in the forest. It allows users to search for resources (like a printer in another domain) without needing to query every single DC in the forest.
SYSVOL Folder
The SYSVOL folder is a shared directory on every DC that stores the domain’s public files, including:
- Login scripts (Netlogon share).
- Group Policy Templates.
- It is kept in sync across all DCs using the File Replication Service (FRS) or DFSR.
Part 3: Protocols and Naming
LDAP (Lightweight Directory Access Protocol)
LDAP is the language used to talk to Active Directory. It follows the X.500 standard and uses TCP/IP.
- Distinguished Name (DN): The full path to an object (e.g.,
CN=JohnDoe,OU=Sales,DC=corp,DC=com). - Relative Distinguished Name (RDN): Just the object’s name (e.g.,
JohnDoe). - UPN (User Principal Name): The “email-style” login name (e.g.,
johndoe@corp.com).
Part 4: Essential Admin Tools
| Tool | Purpose |
| ADSIEdit | A low-level “registry editor” for Active Directory objects and attributes. |
| LDP | A tool for performing LDAP searches and operations manually. |
| Repadmin | The go-to command-line tool for diagnosing replication health. |
| Netdom | Used for managing trust relationships and joining computers to domains via CLI. |
| Dcpromo | (Legacy) The command to promote or demote a Domain Controller. |
Common Interview Scenario: “My Replication is Broken”
Answer: I would start by checking connectivity between sites. Then, I would use repadmin /showrepl to see which naming contexts (Domain, Configuration, or Schema) are failing. I’d also check the DNS SRV records to ensure the DCs can find each other.
#ActiveDirectory #SysAdmin #WindowsServer #ITJobs #TechInterview #Microsoft #Networking #ITOps #LazyAdmin
Installing ADSI Edit on Windows Server 2003

Whether you are performing a schema extension or manually cleaning up metadata after a failed Domain Controller demotion, ADSI Edit is the tool you need. Because it interacts directly with the Active Directory database, it is powerful—and dangerous.
Warning: ADSI Edit does not have “undo” functionality. Always ensure you have a valid System State backup before making manual attribute changes.
Step 1: Locating the Installation Files
On Windows Server 2003, ADSI Edit is not installed by default. It is part of the Windows Support Tools package.
- From the CD: Insert your Windows Server 2003 installation media and navigate to:
[CD-DRIVE]:\SUPPORT\TOOLS\ - Run the Installer: Double-click SUPTOOLS.MSI and follow the installation wizard.
- No CD? You can download the “Windows Server 2003 Service Pack 2 Support Tools” directly from the Microsoft Download Center.
Step 2: Launching the Console
Once the Support Tools are installed, you can launch the editor:
- Go to Start > Run.
- Type
adsiedit.mscand press Enter.
Step 3: Troubleshooting “adsiedit.msc not found”
If you have installed the tools but still receive an error that the file cannot be found, the system likely hasn’t registered the required library (.dll) file properly.
To manually register the DLL:
- Go to Start > Run.
- Type the following command:
regsvr32 adsiedit.dll - You should see a success message stating that the DllRegisterServer succeeded.
What can you do with ADSI Edit?
ADSI Edit allows you to view and edit the three primary partitions of the Active Directory database:
- Domain Partition: Contains the users, groups, and OUs.
- Configuration Partition: Contains forest-wide configuration data (like site topology).
- Schema Partition: Contains the definitions for every object type and attribute in the forest.
#ActiveDirectory #ADSIEdit #WindowsServer #SysAdmin #ITPro #Microsoft #TechSupport #LazyAdmin #ServerManagement #VintageTech #ADTroubleshooting

