From: <CZa...@wi...> - 2002-04-18 13:57:21
|
Hello, I am writing a script to search the LDAP service and return the email addresses for all entries and split them at the "@" sign then sort them. The problem I am having is sorting them I get this error -- "Bad parameter to an ldap routine at email_search.pl line 25." Can anyone help? my @OU = ("AusAsia", "Australia", "Canada", "Chichester", "CPA", "Indianapolis", "JosseyBass", "NewYork605", "NewYork909", "Tulsa", "USDC", " VCH"); $ldap = Net::LDAP->new('server.sys.com', port => '389') || die "ERROR: $@"; $sort = Net::LDAP::Control::Sort->new( order => "sn -mail" ); foreach my $i (@OU) { foreach my $j ("a" .. "z") { @args = ( base => "ou=$i,o=Wiley", scope => "subtree", filter => "(sn=$j*)" ); $r = $ldap->search( @args, control => [ $sort ]); ($ctrl) = $r->control( LDAP_CONTROL_SORTRESULT ); die ldap_error_desc($r->code) if $r->code; if ($ctrl && $ctrl->result) { foreach $entry ($r->entries) { $mail = $entry->get_value('mail'); $cn = $entry->get_value('cn'); if ($mail ne "") { @email = split(/@/, $mail); printf "$i: $email[0]\n"; } else { print "$i: $cn has no email address.\n"; } } } } } |