Sandra Schlichting
Sandra Schlichting

Reputation: 26016

How to list OU's in an OU?

I would like to output all the OU's that are in the test OU.

my $mesg = $ldap->search(
    base => "OU=test,OU=company,DC=example,DC=com",
    scope => 'sub',
    filter => '(objectClass=*)',
    attrs => ['*'],
    );

print Dumper $mesg->entry;

When I do the search like so, I only get information about the test OU, and not which OU's it contain.

Any ideas how to do that?

Upvotes: 2

Views: 7417

Answers (1)

kalyan
kalyan

Reputation: 3106

$mesg will have array of entries. You are trying to print the first entry from the search result.

Try,

print Dumper $mesg

also change your filter to

filter => '(objectClass=organizationalUnit)'

ldapsearch start the search from the base dn and including basedn. Here OU=test,OU=company,DC=example,DC=com is also organizationalunit so this entry is coming as a first entry in the result for you and you are printing only that.

Upvotes: 6

Related Questions