Listing02_Search_RootDSE_Net-LDAP (Perl)

This code can be found in Chapter 3 of Managing Enterprise Active Directory Services

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the Perl code from this site.

# ---------------------------------------------------------------------
# From the book "Managing Enterprise Active Directory Services"
# ISBN: 0-672-32125-4
# Copyright (C) 2002 by Addison-Wesley
# Script by Robbie Allen
# ---------------------------------------------------------------------
$ldap = Net::LDAP->new('dc1.xyz.com')
    or die " Could not connect: $@";
# notice the bind isn't called because it is an anonymous connection
$rootdse = $ldap->search(
                    base   => '',
                    filter => '(objectclass=*)',
                    scope  => 'base',
);
die $rootdse->error if $rootdse->code;
foreach $entry($rootdse->entries) {
   foreach $attr(sort $entry->attributes) {
      print "$attr: $_\n" foreach $entry->get_value($attr);
   }
}

This code has been viewed 865 times.

New from the creators of TechTasks.com: StatSheet.com