From: Chris R. <Chr...@me...> - 2000-07-24 07:55:08
|
On Sat, 22 Jul 2000 21:13:45 CDT, Mark Wilcox wrote: > Try this: > use Net::LDAP; > use Net::LDAP::Util #must import because Net::LDAP doesn't do automatically > > ... > #should print human readable error messages: > print "Error: ",Net:::LDAP::Util($result->code),"\n") if $result->code; (How many colons? :-) Close, but try this instead: use Net::LDAP::Util qw(ldap_error_name); ... print "Error: ", ldap_error_name($result->code), "\n" if $result->code; > Mark > > Kaouass Rachid wrote: > > > Hi, > > > > When I try to show the message of an error it is always an empty string > > ? > > ie. $mesg = ldap->add (.....); > > $mesg->code && warn "erreur on ".$mesg->code." ".$mesg->error."\n"; > > > > should I install a package ? > > > > Thanks > > This is something the documentation could be clearer about. The error() method only returns to you the error text that the LDAP server filled in. However in the LDAP protocol, the error text is optional, and does not have to be filled in. Most servers do not, and you should not write code to ever depend on particular values in this field. If you're curious, see the penultimate paragraph of RFC 2251 section 4.1.10. The only portable thing you can do is to get the error code() and print that. Servers *have* to return a correct result code :-) Mark's pointed out the utility function to convert the result code to a more meaningful error message... Cheers, Chris |