From: Chris R. <not...@ho...> - 2002-07-04 12:28:33
|
ok then from what I can gather its not my dn thats causing me problems its either my search or my error checking...how exactly does this program handle errors? error codes like jcl on the mainfraime? functions like java?? #check for search error if ($error = $results->code()){ die "Critical LDAP search failed:$matchAttr=$name"; } unless($results->count()== 0) { die"User entry not found for:$name"; } because everybody tells me to do it something like the above but if it can assign something to $error will it not come back true? I don't understand that at all >From: Bob...@kp... >To: not...@ho... >CC: per...@li... >Subject: Re: get_dn >Date: Tue, 2 Jul 2002 11:50:28 -0700 > >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 _________________________________________________________________ Chat with friends online, try MSN Messenger: http://messenger.msn.com |