in reply to How to Enum windows ActiveDirectory OU objects
I can't take credit for this approach—I basically translated a solution in O'Reilly's Active Directory Cookbook from VBScript to Perl. If you have to do a lot of AD scripting, this book would probably be a good investment. It's pretty simple to translate its VBScript code into Perl.use Win32::OLE qw(in); showObjects("LDAP://[INSERT DOMAIN NAME HERE]",""); sub showObjects { my ($path, $space) = @_; my $object = Win32::OLE->GetObject($path); print "$space $object->{Name} ($object->{Class})\n"; foreach my $childObject (in $object) { showObjects($childObject->ADsPath, $space . " "); } }
|
|---|