开发者

How to list OU's in an OU?

开发者 https://www.devze.com 2023-02-20 14:14 出处:网络
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\",

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 =&g开发者_开发知识库t; '(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?


$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.

0

精彩评论

暂无评论...
验证码 换一张
取 消