From: <Bob...@kp...> - 2002-07-02 19:18:02
|
I have added a couple of <<<Comments<<< to the code B Chris Ronstadt wrote: >> ok, I am still having problems with the get_dn here is the relevant code: >> my $ldap = Net::LDAP -> new($ldapServer, port => $ldapPort, >> debug=>1) or die >> "LDAP Server Connection Failed :$error"; >>#Annonymous Query to LDAP baseed on DN >>my $results = $ldap->search( >> base => $baseDN, >> scope => "sub", >> filter => ($matchAttr==$name), >> attrs => $attrs >> ); >># request all available attributes >>my @Attrs = (); >> >>#check for search error >> if ($error == $results->code()){ >> die "Critical LDAP search failed:$error,$results->filter(0)"; >> } >> >> if ($results->count()) { <<< count() is the number >> die"User entry not found for filter:&results->filter"; <<< of entries returned. This >> } <<< should read something like << if ($results -> count() == 0).... >> >>#get DN >> $ent = $results -> shift_entry(); <<< You get here only when the >> $dn = $ent -> dn(); #line 39 <<< Search found nothing to return. <<< ergo shift_entry() returns undef. >> >> What I think you want at "#get dn" is: while (my $ent = $results -> shift_entry() ) { print($ent -> dn(), "\n"); } Or something similar. B |