Capturing LDAP error message

[email protected] (Rick Sanders)
Newsgroups perl.ldap
Message-ID <[email protected]>
I am trying to capture a better error description than I am getting with 
the following code:

use Net::LDAP::Util qw(ldap_error_name ldap_error_text ldap_error_desc);

$result = $ldap->add( $dn, attr => [ %$attrs ] );
if ( $result->code ) {
    $error = $result->code;
    $errtxt = ldap_error_name( $result->code );
    Log("      ERROR adding $dn: $errtxt");
    $errtxt = ldap_error_text( $result->code );
    Log("      ERROR adding $dn: $errtxt");
    $errtxt = ldap_error_desc( $result->code );
    Log("      ERROR adding $dn: $errtxt");
}

That gives me the following:

       ERROR adding mail=MILLENNIUMTENS,o=site: LDAP_INVALID_SYNTAX
       ERROR adding mail=MILLENNIUMTENS,o=site: Some part of the request 
contained an invalid syntax. It could be a search with an invalid filter 
or a request to modify the schema and the given schema has a bad syntax.
       ERROR adding mail=MILLENNIUMTENS,o=site: Invalid syntax

If I set $ldap->debug(12) then a ton of info is written to STDERR that 
contains the details I need (showing the value that caused the error).

Net::LDAP=HASH(0x2993f4) received:
0000 30   86: SEQUENCE {
0002 02    1:   INTEGER = 5
0005 69   81:   [APPLICATION 9] {
0007 0A    1:     ENUM = 21
000A 04    0:     STRING = ''
000C 04   74:     STRING = 'Bad SMTP Address; not canonical form, 
Attribute=mail, Value=MILLENNIUMTENS'
0058        :   }
0058        : }

Is there a way in NET::LDAP to grab that error string other than 
redirecting STDERR and parsing it?  "LDAP_INVALID_SYNTAX" is not 
particularly helpful in diagnosing why the syntax was invalid.

Thanks,
Rick
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.