I need to retrieve all Organizational Units from a given DN stringh, I am using Net::LDAP module and this little script:
my $msg = $ldap->search(
base=>'DC=sample1,DC=sample2',
filter=>'(objectclass=User)',
);
foreach $entry ($msg->entries) {
$dn = $entry->dn;
#how can i retrieve OUs?
}
For example if dn returns that string:
CN=Sample Sample,OU=One,OU=Two,DC=sample1,DC=sample2
I want to retrieve One and Two.
Issue a one level search request using the base object
dc=example1,dc=sample2
and a presence filter of(ou=*)
. Given those results, issue a one level search using each returnedou
with a presence filter of(ou=*)
. For each of these searches, specify a size limit and a time limit. For more information on search requests, see "LDAP: Using ldapsearch" and "LDAP: programming practices".