Hi,

another typo:  @enttries  (see the double t) is empty. Thus the empty line

Maybe you should consider using
* using 'perl -c FILENAME' to check for syntax errors in your file
* calling your files with perl -w
  set your 1st line to  '#!/bin/perl -w' and this is done automatically
* 'use strict;' to restrict unsafe construct

CU
PEter



On Tuesday 24 May 2005 18:08, [EMAIL PROTECTED] wrote:
> Hello all,
>
> I am having trouble displaying my LDAP search results using sorting.  I am
> opening a text file parsing out the UID and performing a LDAP search
> filtering using this UID, but I'm not getting the results, just blank
> lines.  Below is the script.  I'm not sure if I am using the
> Net::LDAP::Control::Sort correctly.
>
>
> use Net::LDAP qw(:all);
> use Net::LDAP::Util qw(ldap_error_text);
> use Net::LDAP::Control::Sort;
> use Net::LDAP::Constant qw(LDAP_CONTROL_SORTRESULT);
>
> my $ldapObject = Net::LDAP->new('ldap.host.com') || die "$@";
> my $sorted = Net::LDAP::Control::Sort->new(
>                 order => "departmentnumber"
>         );
>
> open(FH, "< myfile.txt") || die "$@";
>
>
> while (<FH>)
> {
>         my $line = $_;
>         $counter++;
>
>         if ("$counter" < '7')
>         {
>                 next;
>
>         } else {
>
>                 if ($line =~ /^Total/)
>                 {
>                         $total_line = "$line";
>                         next;
>                 } else {
>                         chomp($line);
>                         $line =~ s/\t\t*/ /g;
>                         $line =~ s/\"\"*//g;
>                         $line =~ s/\,\,*//g;
>                         $line =~ s/^(\n)//;
>                         ($iid, $domain, $session, $minutes, $cost) =
> split(/  */, $line);
>                         $sr = $ldapObject->search(
>                                                 base=> 'O=company',
>                                                 scope=> 'sub',
>                                                 filter=>
> "(&(objectclass=jwsPerson)(uid=$iid))",
>                                                 control => [ $sorted ]
>                         );
>
>                         ($resp) = $sr->control( LDAP_CONTROL_SORTRESULT );
>
>                         @entries = $sr->entries;
>                         foreach $entry (@enttries)
>                         {
>                                 $uid = $entry->get_value('uid');
>                                 $fname = $entry->get_value('givvenname');
>                                 $lname = $entry->get_value('sn');
>                                 $location = $entry->get_value('l');
>                                 $deptnum =
> $entry->get_value('departmentnumber');
>
>                         print
> "$uid\t$fname\t$lname\t$location\t$deptnum\n";
>
>                         }
>
>
>                 }
>         }
> }
>
> close(FH);

-- 
Peter Marschall
eMail: [EMAIL PROTECTED]

Reply via email to