From: Graham B. <gb...@po...> - 2002-07-04 13:47:03
|
Your filter looks wrong. You are passing filter => ($matchAttr==$name) The filter needs to be a string, not the result of an expressions. Perl will compare $matchAttr to $name, and as they dont compare it will be passing the string '' What you probably want is filter => "($matchAttr=$name)" Graham. On Thu, Jul 04, 2002 at 08:28:14AM -0400, Chris Ronstadt wrote: > 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 > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Caffeinated soap. No kidding. > http://thinkgeek.com/sf |